Changeset 12391


Ignore:
Timestamp:
Apr 27, 2011, 9:22:08 PM (10 years ago)
Author:
jordan
Message:

(trunk libT) tweak the ABI of tr_bencToBuf() to match the way it's being used

Location:
trunk/libtransmission
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer-http.c

    r12389 r12391  
    212212        if( getenv( "TR_CURL_VERBOSE" ) != NULL )
    213213        {
    214             struct evbuffer * buf = evbuffer_new( );
    215             tr_bencToBuf( &benc, TR_FMT_JSON, buf );
     214            struct evbuffer * buf = tr_bencToBuf( &benc, TR_FMT_JSON );
    216215            fprintf( stderr, "Announce response:\n< %s\n", evbuffer_pullup( buf, -1 ) );
    217216            tr_free( buf );
  • trunk/libtransmission/bencode-test.c

    r12228 r12391  
    324324
    325325    tr_bencLoad( benc_str, strlen( benc_str ), &top, NULL );
    326     tr_bencToBuf( &top, TR_FMT_JSON, buf );
     326    buf = tr_bencToBuf( &top, TR_FMT_JSON );
    327327    serialized = (char*) evbuffer_pullup( buf, -1 );
    328328    stripWhitespace( serialized );
  • trunk/libtransmission/bencode.c

    r12275 r12391  
    16071607***/
    16081608
    1609 void
    1610 tr_bencToBuf( const tr_benc * top, tr_fmt_mode mode, struct evbuffer * buf )
    1611 {
    1612     evbuffer_drain( buf, evbuffer_get_length( buf ) );
     1609struct evbuffer *
     1610tr_bencToBuf( const tr_benc * top, tr_fmt_mode mode )
     1611{
     1612    struct evbuffer * buf = evbuffer_new( );
     1613
    16131614    evbuffer_expand( buf, 4096 ); /* alloc a little memory to start off with */
    16141615
     
    16311632        }
    16321633    }
     1634
     1635    return buf;
    16331636}
    16341637
     
    16361639tr_bencToStr( const tr_benc * top, tr_fmt_mode mode, int * len )
    16371640{
    1638     char * ret;
    1639     struct evbuffer * buf = evbuffer_new( );
    1640     size_t n;
    1641     tr_bencToBuf( top, mode, buf );
    1642     n = evbuffer_get_length( buf );
    1643     ret = evbuffer_free_to_str( buf );
     1641    struct evbuffer * buf = tr_bencToBuf( top, mode );
     1642    const size_t n = evbuffer_get_length( buf );
     1643    char * ret = evbuffer_free_to_str( buf );
    16441644    if( len != NULL )
    16451645        *len = (int) n;
  • trunk/libtransmission/bencode.h

    r12204 r12391  
    126126char* tr_bencToStr( const tr_benc *, tr_fmt_mode, int * len );
    127127
    128 void tr_bencToBuf( const tr_benc *, tr_fmt_mode, struct evbuffer * );
     128struct evbuffer * tr_bencToBuf( const tr_benc *, tr_fmt_mode );
    129129
    130130/* TR_FMT_JSON_LEAN and TR_FMT_JSON are equivalent in this function. */
  • trunk/libtransmission/rpc-server.c

    r12229 r12391  
    271271            if( have_source )
    272272            {
    273                 struct evbuffer * json = evbuffer_new( );
    274                 tr_bencToBuf( &top, TR_FMT_JSON, json );
     273                struct evbuffer * json = tr_bencToBuf( &top, TR_FMT_JSON );
    275274                tr_rpc_request_exec_json( server->session,
    276275                                          evbuffer_pullup( json, -1 ),
  • trunk/libtransmission/rpcimpl.c

    r12248 r12391  
    9595tr_idle_function_done( struct tr_rpc_idle_data * data, const char * result )
    9696{
    97     struct evbuffer * buf = evbuffer_new( );
     97    struct evbuffer * buf;
    9898
    9999    if( result == NULL )
     
    101101    tr_bencDictAddStr( data->response, "result", result );
    102102
    103     tr_bencToBuf( data->response, TR_FMT_JSON_LEAN, buf );
     103    buf = tr_bencToBuf( data->response, TR_FMT_JSON_LEAN );
    104104    (*data->callback)( data->session, buf, data->callback_user_data );
    105 
    106105    evbuffer_free( buf );
     106
    107107    tr_bencFree( data->response );
    108108    tr_free( data->response );
     
    17161716        int64_t tag;
    17171717        tr_benc response;
    1718         struct evbuffer * buf = evbuffer_new( );
     1718        struct evbuffer * buf;
    17191719
    17201720        tr_bencInitDict( &response, 3 );
     
    17231723        if( tr_bencDictFindInt( request, "tag", &tag ) )
    17241724            tr_bencDictAddInt( &response, "tag", tag );
    1725         tr_bencToBuf( &response, TR_FMT_JSON_LEAN, buf );
     1725
     1726        buf = tr_bencToBuf( &response, TR_FMT_JSON_LEAN );
    17261727        (*callback)( session, buf, callback_user_data );
    1727 
    17281728        evbuffer_free( buf );
     1729
    17291730        tr_bencFree( &response );
    17301731    }
     
    17341735        tr_benc response;
    17351736        tr_benc * args_out;
    1736         struct evbuffer * buf = evbuffer_new( );
     1737        struct evbuffer * buf;
    17371738
    17381739        tr_bencInitDict( &response, 3 );
     
    17441745        if( tr_bencDictFindInt( request, "tag", &tag ) )
    17451746            tr_bencDictAddInt( &response, "tag", tag );
    1746         tr_bencToBuf( &response, TR_FMT_JSON_LEAN, buf );
     1747
     1748        buf = tr_bencToBuf( &response, TR_FMT_JSON_LEAN );
    17471749        (*callback)( session, buf, callback_user_data );
    1748 
    17491750        evbuffer_free( buf );
     1751
    17501752        tr_bencFree( &response );
    17511753    }
Note: See TracChangeset for help on using the changeset viewer.