Changeset 12290


Ignore:
Timestamp:
Apr 1, 2011, 3:09:24 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) streamline parsing the metainfo's file list

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/metainfo.c

    r12230 r12290  
    148148
    149149static bool
    150 getfile( char ** setme, const char * root, tr_benc * path )
     150getfile( char ** setme, const char * root, tr_benc * path, struct evbuffer * buf )
    151151{
    152152    bool success = false;
     
    155155    {
    156156        int i;
    157         char * tmp;
    158157        const int n = tr_bencListSize( path );
    159         struct evbuffer * buf = evbuffer_new( );
    160 
     158
     159        evbuffer_drain( buf, evbuffer_get_length( buf ) );
    161160        evbuffer_add( buf, root, strlen( root ) );
    162161        for( i = 0; i < n; ++i )
     
    170169        }
    171170
    172         tmp = evbuffer_free_to_str( buf );
    173         *setme = tr_utf8clean( tmp, -1 );
    174         tr_free( tmp );
     171        *setme = tr_utf8clean( (char*)evbuffer_pullup( buf, -1 ), evbuffer_get_length( buf ) );
    175172        /* fprintf( stderr, "[%s]\n", *setme ); */
    176173        success = true;
     
    197194    {
    198195        tr_file_index_t i;
     196        struct evbuffer * buf = evbuffer_new( );
    199197
    200198        inf->isMultifile = 1;
     
    215213                    return "path";
    216214
    217             if( !getfile( &inf->files[i].name, inf->name, path ) )
     215            if( !getfile( &inf->files[i].name, inf->name, path, buf ) )
    218216                return "path";
    219217
     
    224222            inf->totalSize      += len;
    225223        }
     224
     225        evbuffer_free( buf );
    226226    }
    227227    else if( tr_bencGetInt( length, &len ) ) /* single-file mode */
Note: See TracChangeset for help on using the changeset viewer.