Changeset 9464
- Timestamp:
- Nov 1, 2009, 1:35:06 AM (13 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/request-list.c
r8889 r9464 76 76 77 77 void 78 reqListAppend( struct request_list * list, 79 const struct peer_request * req ) 78 reqListAppend( struct request_list * list, const struct peer_request * req ) 80 79 { 81 80 int low; 81 tr_bool exact; 82 82 83 83 reqListReserve( list, list->len + 8 ); … … 87 87 88 88 /* insert into list->sort */ 89 low = reqListSortPos( list, req, NULL);89 low = reqListSortPos( list, req, &exact ); 90 90 memmove( &list->sort[low+1], &list->sort[low], (list->len-low)*sizeof(struct peer_request) ); 91 91 list->sort[low] = *req; -
trunk/libtransmission/utils.c
r9463 r9464 1083 1083 } 1084 1084 1085 int1086 tr_ptr2int( void* v )1087 {1088 return (intptr_t)v;1089 }1090 1091 void*1092 tr_int2ptr( int i )1093 {1094 return (void*)(intptr_t)i;1095 }1096 1097 1085 /*** 1098 1086 **** … … 1110 1098 const char * cbase = base; 1111 1099 tr_bool exact = FALSE; 1112 int c; 1113 1114 while( nmemb ) 1100 1101 while( nmemb != 0 ) 1115 1102 { 1116 1103 const size_t half = nmemb / 2; 1117 1104 const size_t middle = first + half; 1118 c = compar( key, cbase + size*middle );1105 const int c = compar( key, cbase + size*middle ); 1119 1106 1120 1107 if( c <= 0 ) { … … 1128 1115 } 1129 1116 1130 if( exact_match ) 1131 *exact_match = exact; 1117 *exact_match = exact; 1132 1118 1133 1119 return first; -
trunk/libtransmission/utils.h
r9421 r9464 55 55 #ifndef TR_GNUC_PRINTF 56 56 #ifdef __GNUC__ 57 #define TR_GNUC_PRINTF( fmt,\ 58 args ) __attribute__ ( ( format ( printf, fmt,\ 59 args ) ) ) 57 #define TR_GNUC_PRINTF( fmt, args ) __attribute__ ( ( format ( printf, fmt, args ) ) ) 60 58 #else 61 59 #define TR_GNUC_PRINTF( fmt, args ) … … 63 61 #endif 64 62 63 #ifndef TR_GNUC_NONNULL 64 #ifdef __GNUC__ 65 #define TR_GNUC_NONNULL( ... ) __attribute__((nonnull (__VA_ARGS__))) 66 #else 67 #define TR_GNUC_NONNULL( ... ) 68 #endif 69 #endif 70 65 71 #ifndef TR_GNUC_NULL_TERMINATED 66 72 #if __GNUC__ >= 4 67 73 #define TR_GNUC_NULL_TERMINATED __attribute__ ( ( __sentinel__ ) ) 74 #define TR_GNUC_HOT __attribute ( ( hot ) ) 68 75 #else 69 76 #define TR_GNUC_NULL_TERMINATED 77 #define TR_GNUC_HOT 70 78 #endif 71 79 #endif … … 189 197 const char * name, 190 198 const char * fmt, 191 ... ) TR_GNUC_PRINTF( 4, 5 ) ;199 ... ) TR_GNUC_PRINTF( 4, 5 ) TR_GNUC_NONNULL(1,4); 192 200 193 201 char* tr_getLogTimeStr( char * buf, 194 int buflen ) ;202 int buflen ) TR_GNUC_NONNULL(1); 195 203 196 204 197 205 int tr_wildmat( const char * text, 198 const char * pattern ) ;206 const char * pattern ) TR_GNUC_NONNULL(1,2); 199 207 200 208 /** @brief Portability wrapper for basename() that uses the system implementation if available */ … … 214 222 */ 215 223 int tr_mkdir( const char * path, 216 int permissions ) ;224 int permissions ) TR_GNUC_NONNULL(1); 217 225 218 226 /** … … 222 230 * (in which case errno is set appropriately). 223 231 */ 224 int tr_mkdirp( const char * path, int permissions ) ;232 int tr_mkdirp( const char * path, int permissions ) TR_GNUC_NONNULL(1); 225 233 226 234 … … 229 237 * On failure, NULL is returned and errno is set. 230 238 */ 231 uint8_t* tr_loadFile( const char * filename, size_t * size ) TR_GNUC_MALLOC ;239 uint8_t* tr_loadFile( const char * filename, size_t * size ) TR_GNUC_MALLOC TR_GNUC_NONNULL(1); 232 240 233 241 … … 324 332 size_t size, 325 333 int (* compar)(const void* key, const void* arrayMember), 326 tr_bool * exact_match ) ;334 tr_bool * exact_match ) TR_GNUC_HOT TR_GNUC_NONNULL(1,5,6); 327 335 328 336 … … 343 351 /** @brief Portability wrapper for snprintf() that uses the system implementation if available */ 344 352 int tr_snprintf( char * buf, size_t buflen, 345 const char * fmt, ... ) TR_GNUC_PRINTF( 3, 4 ) ;353 const char * fmt, ... ) TR_GNUC_PRINTF( 3, 4 ) TR_GNUC_NONNULL(1,3); 346 354 347 355 const char* tr_strerror( int ); … … 361 369 typedef void ( tr_set_func )( void * element, void * userData ); 362 370 363 void tr_set_compare( const void * a, 364 size_t aCount, 365 const void * b, 366 size_t bCount, 371 void tr_set_compare( const void * a, size_t aCount, 372 const void * b, size_t bCount, 367 373 int compare( const void * a, const void * b ), 368 374 size_t elementSize, … … 373 379 374 380 void tr_sha1_to_hex( char * out, 375 const uint8_t * sha1 ) ;376 377 378 tr_bool tr_httpIsValidURL( const char * url ) ;381 const uint8_t * sha1 ) TR_GNUC_NONNULL(1,2); 382 383 384 tr_bool tr_httpIsValidURL( const char * url ) TR_GNUC_NONNULL(1); 379 385 380 386 int tr_httpParseURL( const char * url, … … 382 388 char ** setme_host, 383 389 int * setme_port, 384 char ** setme_path ) ;390 char ** setme_path ) TR_GNUC_NONNULL(1); 385 391 386 392 double tr_getRatio( double numerator, double denominator ); 387 393 388 int* tr_parseNumberRange( const char * str, int str_len, int * setmeCount ) TR_GNUC_MALLOC; 389 390 391 int tr_ptr2int( void* ); 392 393 void* tr_int2ptr( int ); 394 int* tr_parseNumberRange( const char * str, int str_len, int * setmeCount ) TR_GNUC_MALLOC TR_GNUC_NONNULL(1); 395 394 396 395 397 /* truncate a double value at a given number of decimal places. … … 413 415 * @param the string represntation of "infinity" 414 416 */ 415 char* tr_strratio( char * buf, size_t buflen, double ratio, const char * infinity ) ;417 char* tr_strratio( char * buf, size_t buflen, double ratio, const char * infinity ) TR_GNUC_NONNULL(1,4); 416 418 417 419 /** @brief Portability wrapper for localtime_r() that uses the system implementation if available */ … … 420 422 421 423 /** on success, return 0. on failure, return -1 and set errno */ 422 int tr_moveFile( const char * oldpath, const char * newpath, tr_bool * renamed ) ;424 int tr_moveFile( const char * oldpath, const char * newpath, tr_bool * renamed ) TR_GNUC_NONNULL(1,2); 423 425 424 426
Note: See TracChangeset
for help on using the changeset viewer.