Ignore:
Timestamp:
Jan 2, 2009, 8:12:23 PM (12 years ago)
Author:
charles
Message:

(trunk libT) make the tr_bandwidth macros into safer inline funcs. inline utils' one-liners.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils.c

    r7574 r7581  
    643643****/
    644644
    645 void*
    646 tr_memdup( const void * in,
    647            int          byteCount )
    648 {
    649     void * out = tr_new( uint8_t, byteCount );
    650 
    651     memcpy( out, in, byteCount );
    652     return out;
    653 }
    654 
    655 char*
    656 tr_strdup( const void * in )
    657 {
    658     return tr_strndup( in, in ? strlen( (const char*)in ) : 0 );
    659 }
    660 
    661645char*
    662646tr_strndup( const void * in,
     
    695679    tr_releaseBuffer( buf );
    696680    return ret;
    697 }
    698 
    699 void*
    700 tr_malloc( size_t size )
    701 {
    702     return size ? malloc( size ) : NULL;
    703 }
    704 
    705 void*
    706 tr_malloc0( size_t size )
    707 {
    708     return size ? calloc( 1, size ) : NULL;
    709 }
    710 
    711 void
    712 tr_free( void * p )
    713 {
    714     if( p )
    715         free( p );
    716681}
    717682
     
    767732}
    768733
    769 void
     734tr_bitfield*
    770735tr_bitfieldDestruct( tr_bitfield * b )
    771736{
    772     tr_free( b->bits );
    773 }
    774 
    775 tr_bitfield*
    776 tr_bitfieldNew( size_t bitCount )
    777 {
    778     return tr_bitfieldConstruct( tr_new0( tr_bitfield, 1 ), bitCount );
     737    if( b )
     738        tr_free( b->bits );
     739    return b;
    779740}
    780741
     
    788749    ret->bits = tr_memdup( in->bits, in->byteCount );
    789750    return ret;
    790 }
    791 
    792 void
    793 tr_bitfieldFree( tr_bitfield * bitfield )
    794 {
    795     if( bitfield )
    796     {
    797         tr_bitfieldDestruct( bitfield );
    798         tr_free( bitfield );
    799     }
    800751}
    801752
Note: See TracChangeset for help on using the changeset viewer.