Changeset 6069
- Timestamp:
- Jun 6, 2008, 11:53:30 PM (14 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/utils.c
r6058 r6069 589 589 ****/ 590 590 591 void* 592 tr_memdup( const void * in, int byteCount ) 593 { 594 void * out = tr_new( uint8_t, byteCount ); 595 memcpy( out, in, byteCount ); 596 return out; 597 } 598 591 599 char* 592 600 tr_strdup( const char * in ) … … 693 701 tr_bitfield * ret = calloc( 1, sizeof(tr_bitfield) ); 694 702 ret->len = in->len; 695 ret->bits = malloc( ret->len ); 696 memcpy( ret->bits, in->bits, ret->len ); 703 ret->bits = tr_memdup( in->bits, in->len ); 697 704 return ret; 698 705 } -
trunk/libtransmission/utils.h
r6058 r6069 191 191 char* tr_strdup( const char * str ) TR_GNUC_MALLOC; 192 192 char* tr_strndup( const char * str, int len ) TR_GNUC_MALLOC; 193 void* tr_memdup( const void * src, int byteCount ) TR_GNUC_MALLOC; 193 194 char* tr_strdup_printf( const char * fmt, ... ) TR_GNUC_PRINTF( 1, 2 ) TR_GNUC_MALLOC; 194 195 char* tr_base64_encode( const void * input, int inlen, int *outlen ) TR_GNUC_MALLOC; … … 272 273 /** @param high the highest nth bit you're going to access */ 273 274 #define tr_bitfieldTestFast(bitfield,high) \ 274 ((bitfield) && ( (bitfield)->bits ) && ( ( (high)>>3u) < (bitfield)->len))275 ((bitfield) && ( (bitfield)->bits ) && ( (high) <= (bitfield)->len*8 )) 275 276 276 277 double tr_getRatio( double numerator, double denominator );
Note: See TracChangeset
for help on using the changeset viewer.