Changeset 12392


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

(trunk libT) heap pruning: using the same mechanism as in r12388, avoid an unnecessary malloc+memcpy+free in tr_bencToFile()

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bencode.c

    r12391 r12392  
    16841684        /* save the benc to a temporary file */
    16851685        {
    1686             char * buf = tr_bencToStr( top, mode, &nleft );
    1687             const char * walk = buf;
     1686            struct evbuffer * buf = tr_bencToBuf( top, mode );
     1687            const char * walk = (const char *) evbuffer_pullup( buf, -1 );
     1688            nleft = evbuffer_get_length( buf );
     1689
    16881690            while( nleft > 0 ) {
    16891691                const int n = write( fd, walk, nleft );
     
    16971699                }
    16981700            }
    1699             tr_free( buf );
     1701
     1702            evbuffer_free( buf );
    17001703        }
    17011704
Note: See TracChangeset for help on using the changeset viewer.