Changeset 8685


Ignore:
Timestamp:
Jun 14, 2009, 1:00:36 AM (13 years ago)
Author:
charles
Message:

(trunk libT) remove the last calls to tr_getBuffer() and tr_releaseBuffer()

Location:
trunk/libtransmission
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode-test.c

    r8588 r8685  
    321321{
    322322    tr_benc top;
    323     struct evbuffer * buf = tr_getBuffer( );
     323    struct evbuffer * buf = evbuffer_new( );
    324324    char * serialized;
    325325
     
    335335    check( !strcmp( serialized, expected ) );
    336336    tr_bencFree( &top );
    337     tr_releaseBuffer( buf );
     337    evbuffer_free( buf );
    338338    return 0;
    339339}
  • trunk/libtransmission/handshake.c

    r8565 r8685  
    333333    int               len;
    334334    const uint8_t *   public_key;
    335     struct evbuffer * outbuf = tr_getBuffer( );
     335    struct evbuffer * outbuf = evbuffer_new( );
    336336    uint8_t           pad_a[PadA_MAXLEN];
    337337
     
    352352
    353353    /* cleanup */
    354     tr_releaseBuffer( outbuf );
     354    evbuffer_free( outbuf );
    355355}
    356356
     
    445445    /* now send these: HASH('req1', S), HASH('req2', SKEY) xor HASH('req3', S),
    446446     * ENCRYPT(VC, crypto_provide, len(PadC), PadC, len(IA)), ENCRYPT(IA) */
    447     outbuf = tr_getBuffer( );
     447    outbuf = evbuffer_new( );
    448448
    449449    /* HASH('req1', S) */
     
    502502
    503503    /* cleanup */
    504     tr_releaseBuffer( outbuf );
     504    evbuffer_free( outbuf );
    505505    return READ_LATER;
    506506}
     
    936936
    937937    tr_cryptoEncryptInit( handshake->crypto );
    938     outbuf = tr_getBuffer( );
     938    outbuf = evbuffer_new( );
    939939
    940940    dbgmsg( handshake, "sending vc" );
     
    956956    {
    957957        dbgmsg( handshake, "peer didn't offer an encryption mode we like." );
    958         tr_releaseBuffer( outbuf );
     958        evbuffer_free( outbuf );
    959959        return tr_handshakeDone( handshake, FALSE );
    960960    }
     
    988988    /* send it out */
    989989    tr_peerIoWriteBuf( handshake->io, outbuf, FALSE );
    990     tr_releaseBuffer( outbuf );
     990    evbuffer_free( outbuf );
    991991
    992992    /* now await the handshake */
  • trunk/libtransmission/metainfo.c

    r8588 r8685  
    6262{
    6363    char *            ret;
    64     struct evbuffer * buf = tr_getBuffer( );
     64    struct evbuffer * buf = evbuffer_new( );
    6565
    6666    evbuffer_add_printf( buf, "%s%c%s", tr_getTorrentDir( session ),
     
    7171
    7272    ret = tr_strndup( EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ) );
    73     tr_releaseBuffer( buf );
     73    evbuffer_free( buf );
    7474    return ret;
    7575}
     
    138138    else
    139139    {
    140         struct evbuffer * buf = tr_getBuffer( );
     140        struct evbuffer * buf = evbuffer_new( );
    141141        int               n = tr_bencListSize( path );
    142142        int               i;
     
    156156        *setme = tr_utf8clean( (char*)EVBUFFER_DATA( buf ), EVBUFFER_LENGTH( buf ), NULL );
    157157        /* fprintf( stderr, "[%s]\n", *setme ); */
    158         tr_releaseBuffer( buf );
     158        evbuffer_free( buf );
    159159        err = 0;
    160160    }
     
    235235               strrchr( announce, '/' ) ) ) && !strncmp( ++s, "announce", 8 ) )
    236236    {
    237         struct evbuffer * buf = tr_getBuffer( );
     237        struct evbuffer * buf = evbuffer_new( );
    238238        evbuffer_add( buf, announce, s - announce );
    239239        evbuffer_add( buf, "scrape", 6 );
    240240        evbuffer_add_printf( buf, "%s", s + 8 );
    241241        scrape = tr_strdup( EVBUFFER_DATA( buf ) );
    242         tr_releaseBuffer( buf );
     242        evbuffer_free( buf );
    243243    }
    244244
  • trunk/libtransmission/peer-msgs.c

    r8664 r8685  
    210210        va_list           args;
    211211        char              timestr[64];
    212         struct evbuffer * buf = tr_getBuffer( );
     212        struct evbuffer * buf = evbuffer_new( );
    213213        char *            base = tr_basename( file );
    214214
     
    226226
    227227        tr_free( base );
    228         tr_releaseBuffer( buf );
     228        evbuffer_free( buf );
    229229    }
    230230}
  • trunk/libtransmission/rpc-server.c

    r8599 r8685  
    125125{
    126126    const char *      code_text = tr_webGetResponseStr( code );
    127     struct evbuffer * body = tr_getBuffer( );
     127    struct evbuffer * body = evbuffer_new( );
    128128
    129129    evbuffer_add_printf( body, "<h1>%d: %s</h1>", code, code_text );
     
    132132    evhttp_send_reply( req, code, code_text, body );
    133133
    134     tr_releaseBuffer( body );
     134    evbuffer_free( body );
    135135}
    136136
     
    416416
    417417            errno = error;
    418             out = tr_getBuffer( );
     418            out = evbuffer_new( );
    419419            evhttp_add_header( req->output_headers, "Content-Type", mimetype_guess( filename ) );
    420420            add_time_header( req->output_headers, "Date", now );
     
    423423            evhttp_send_reply( req, HTTP_OK, "OK", out );
    424424
    425             tr_releaseBuffer( out );
     425            evbuffer_free( out );
    426426            tr_free( content );
    427427        }
     
    490490{
    491491    struct rpc_response_data * data = user_data;
    492     struct evbuffer * buf = tr_getBuffer( );
     492    struct evbuffer * buf = evbuffer_new( );
    493493
    494494    add_response( data->req, data->server, buf, response, response_len );
     
    497497    evhttp_send_reply( data->req, HTTP_OK, "OK", buf );
    498498
    499     tr_releaseBuffer( buf );
     499    evbuffer_free( buf );
    500500    tr_free( data );
    501501}
  • trunk/libtransmission/utils.c

    r8681 r8685  
    260260        va_list           args;
    261261        char              timestr[64];
    262         struct evbuffer * buf = tr_getBuffer( );
     262        struct evbuffer * buf = evbuffer_new( );
    263263        char *            base = tr_basename( file );
    264264
     
    277277
    278278        tr_free( base );
    279         tr_releaseBuffer( buf );
     279        evbuffer_free( buf );
    280280    }
    281281}
     
    737737    va_list           ap;
    738738
    739     buf = tr_getBuffer( );
     739    buf = evbuffer_new( );
    740740    va_start( ap, fmt );
    741741
     
    744744
    745745    va_end( ap );
    746     tr_releaseBuffer( buf );
     746    evbuffer_free( buf );
    747747    return ret;
    748748}
     
    13121312***/
    13131313
    1314 static tr_list * _bufferList = NULL;
    1315 
    1316 static tr_lock *
    1317 getBufferLock( void )
    1318 {
    1319     static tr_lock * lock = NULL;
    1320     if( lock == NULL )
    1321         lock = tr_lockNew( );
    1322     return lock;
    1323 }
    1324 
    1325 struct evbuffer*
    1326 tr_getBuffer( void )
    1327 {
    1328     struct evbuffer * buf;
    1329     tr_lock * l = getBufferLock( );
    1330     tr_lockLock( l );
    1331 
    1332     buf = tr_list_pop_front( &_bufferList );
    1333     if( buf == NULL )
    1334         buf = evbuffer_new( );
    1335 
    1336     tr_lockUnlock( l );
    1337     return buf;
    1338 }
    1339 
    1340 void
    1341 tr_releaseBuffer( struct evbuffer * buf )
    1342 {
    1343     tr_lock * l = getBufferLock( );
    1344     tr_lockLock( l );
    1345 
    1346     evbuffer_drain( buf, EVBUFFER_LENGTH( buf ) );
    1347     assert( EVBUFFER_LENGTH( buf ) == 0 );
    1348     tr_list_prepend( &_bufferList, buf );
    1349 
    1350     tr_lockUnlock( l );
    1351 }
    1352 
    1353 /***
    1354 ****
    1355 ***/
    1356 
    13571314int
    13581315tr_lowerBound( const void * key,
  • trunk/libtransmission/utils.h

    r8681 r8685  
    265265***/
    266266
    267 struct evbuffer;
    268 
    269 /** @brief pool of reusable buffers
    270     @see tr_releaseBuffer() */
    271 struct evbuffer * tr_getBuffer( void );
    272 
    273 /** @brief return a buffer to the pool
    274     @see tr_getBuffer() */
    275 void tr_releaseBuffer( struct evbuffer * buf );
    276 
    277 
    278 /***
    279 ****
    280 ***/
    281 
    282267/* Sometimes the system defines MAX/MIN, sometimes not.
    283268   In the latter case, define those here since we will use them */
  • trunk/libtransmission/webseed.c

    r7874 r8685  
    100100{
    101101    char *            ret;
    102     struct evbuffer * out = tr_getBuffer( );
     102    struct evbuffer * out = evbuffer_new( );
    103103    const char *      url = w->url;
    104104    const size_t      url_len = strlen( url );
     
    141141
    142142    ret = tr_strndup( EVBUFFER_DATA( out ), EVBUFFER_LENGTH( out ) );
    143     tr_releaseBuffer( out );
     143    evbuffer_free( out );
    144144    return ret;
    145145}
Note: See TracChangeset for help on using the changeset viewer.