Changeset 5838
- Timestamp:
- May 15, 2008, 3:44:51 PM (14 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/utils.c
r5759 r5838 603 603 } 604 604 605 char* 606 tr_strdup_printf( const char * fmt, ... ) 607 { 608 char * ret = NULL; 609 struct evbuffer * buf; 610 va_list ap; 611 612 buf = evbuffer_new( ); 613 va_start( ap, fmt ); 614 if( evbuffer_add_vprintf( buf, fmt, ap ) != -1 ) 615 ret = tr_strdup( (char*)EVBUFFER_DATA( buf ) ); 616 evbuffer_free( buf ); 617 618 return ret; 619 } 620 605 621 void* 606 622 tr_calloc( size_t nmemb, size_t size ) -
trunk/libtransmission/utils.h
r5759 r5838 31 31 #include <stdio.h> /* FILE* */ 32 32 33 void tr_msgInit( void ); 33 /*** 34 **** 35 ***/ 36 37 #ifndef UNUSED 38 #ifdef __GNUC__ 39 #define UNUSED __attribute__((unused)) 40 #else 41 #define UNUSED 42 #endif 43 #endif 44 45 #ifndef TR_GNUC_PRINTF 46 #ifdef __GNUC__ 47 #define TR_GNUC_PRINTF( fmt, args ) __attribute__((format (printf, fmt, args))) 48 #else 49 #define TR_GNUC_PRINTF( fmt, args ) 50 #endif 51 #endif 52 53 #ifndef TR_GNUC_NULL_TERMINATED 54 #if __GNUC__ >= 4 55 #define TR_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) 56 #else 57 #define TR_GNUC_NULL_TERMINATED 58 #endif 59 #endif 60 61 #ifndef TR_GNUC_NULL_TERMINATED 62 #if __GNUC__ >= 4 63 #define TR_GNUC_NULL_TERMINATED __attribute__((__sentinel__)) 64 #else 65 #define TR_GNUC_NULL_TERMINATED 66 #endif 67 #endif 68 69 #if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96) 70 #define TR_GNUC_PURE __attribute__((__pure__)) 71 #define TR_GNUC_MALLOC __attribute__((__malloc__)) 72 #else 73 #define TR_GNUC_PURE 74 #define TR_GNUC_MALLOC 75 #endif 76 77 78 /*** 79 **** 80 ***/ 34 81 35 82 #if !defined(_) … … 55 102 #define tr_inf( a... ) tr_msg( __FILE__, __LINE__, TR_MSG_INF, NULL, ## a ) 56 103 #define tr_dbg( a... ) tr_msg( __FILE__, __LINE__, TR_MSG_DBG, NULL, ## a ) 57 void tr_msg ( const char * file, int line, int level, const char * torrent, const char * fmt, ... ); 104 105 void tr_msgInit( void ); 106 107 void tr_msg( const char * file, int line, 108 int level, const char * torrent, 109 const char * fmt, ... ) TR_GNUC_PRINTF( 5, 6 ); 110 58 111 FILE* tr_getLog( void ); 59 112 60 void tr_deepLog( const char * file, int line, const char * name, const char * fmt, ... ); 113 void tr_deepLog( const char * file, int line, 114 const char * name, 115 const char * fmt, ... ) TR_GNUC_PRINTF( 4, 5 ); 61 116 62 117 char* tr_getLogTimeStr( char * buf, int buflen ); … … 83 138 84 139 85 uint8_t* tr_loadFile( const char * filename, size_t * size ) ;140 uint8_t* tr_loadFile( const char * filename, size_t * size ) TR_GNUC_MALLOC; 86 141 87 142 … … 89 144 correct separator for filenames. */ 90 145 void tr_buildPath( char* buf, size_t buflen, 91 const char * first_element, ... ); 146 const char * first_element, ... ) 147 TR_GNUC_NULL_TERMINATED; 92 148 93 149 struct timeval tr_timevalMsec( uint64_t milliseconds ); … … 128 184 ((struct_type *) realloc ((mem), ((size_t) sizeof (struct_type)) * ((size_t) (n_structs)))) 129 185 130 void* tr_malloc ( size_t ) ;131 void* tr_malloc0 ( size_t ) ;132 void* tr_calloc ( size_t nmemb, size_t size ) ;186 void* tr_malloc ( size_t ) TR_GNUC_MALLOC; 187 void* tr_malloc0 ( size_t ) TR_GNUC_MALLOC; 188 void* tr_calloc ( size_t nmemb, size_t size ) TR_GNUC_MALLOC; 133 189 void tr_free ( void* ); 134 190 135 char* tr_strdup( const char * str ); 136 char* tr_strndup( const char * str, int len ); 191 char* tr_strdup( const char * str ) TR_GNUC_MALLOC; 192 char* tr_strndup( const char * str, int len ) TR_GNUC_MALLOC; 193 char* tr_strdup_printf( const char * fmt, ... ) TR_GNUC_PRINTF( 1, 2 ) TR_GNUC_MALLOC; 137 194 138 195 const char* tr_strerror( int ); … … 181 238 typedef struct tr_bitfield tr_bitfield_t; 182 239 183 tr_bitfield* tr_bitfieldNew( size_t bitcount ) ;184 tr_bitfield* tr_bitfieldDup( const tr_bitfield* ) ;240 tr_bitfield* tr_bitfieldNew( size_t bitcount ) TR_GNUC_MALLOC; 241 tr_bitfield* tr_bitfieldDup( const tr_bitfield* ) TR_GNUC_MALLOC; 185 242 void tr_bitfieldFree( tr_bitfield*); 186 243
Note: See TracChangeset
for help on using the changeset viewer.