comparison src/util.c @ 281:5eece4dfd945 noffle

[svn] * src/log.c,src/log.h: Add Log_fatal() for reporting fatal errors and exiting, Log_gdbm_fatal() for the the same but specifically as a GDBM error reporting function, and a new log debug level AUTH for a forthcoming authentication mechanism. * src/database.c,src/group.c: Provide new gdbm error function to all gdbm opens. * src/noffle.c: Add atexit() to always close databases on a program- inspired exit. * src/content.c,src/dynamicstring.c,src/fetchlist.c,src/filter.c, src/itemlist.c,src/log.c,src/log.h,src/over.c,src/protocol.h, src/request.c,src/util.c: Use Log_fatal where appropriate.
author bears
date Fri, 27 Dec 2002 21:48:25 +0000
parents 49b452b667a6
children 4426fde0a72c
comparison
equal deleted inserted replaced
280:9c54bf672ca1 281:5eece4dfd945
1 /* 1 /*
2 util.c 2 util.c
3 3
4 $Id: util.c 411 2002-11-17 15:18:19Z bears $ 4 $Id: util.c 413 2002-12-27 21:48:25Z bears $
5 */ 5 */
6 6
7 #if HAVE_CONFIG_H 7 #if HAVE_CONFIG_H
8 #include <config.h> 8 #include <config.h>
9 #endif 9 #endif
555 } 555 }
556 556
557 void 557 void
558 Utl_allocAndCpy( char **dst, const char *src ) 558 Utl_allocAndCpy( char **dst, const char *src )
559 { 559 {
560 int len = strlen( src ); 560 size_t len = strlen( src );
561 if ( ! ( *dst = malloc( (size_t)len + 1 ) ) ) 561 if ( ! ( *dst = malloc( len + 1 ) ) )
562 { 562 Log_fatal( "Cannot allocate string with length %lu", len );
563 Log_err( "Cannot allocate string with length %lu", strlen( src ) ); 563 memcpy( *dst, src, len + 1 );
564 exit( EXIT_FAILURE );
565 }
566 memcpy( *dst, src, (size_t)len + 1 );
567 } 564 }
568 565
569 SignalHandler 566 SignalHandler
570 Utl_installSignalHandler( int sig, SignalHandler handler ) 567 Utl_installSignalHandler( int sig, SignalHandler handler )
571 { 568 {