Changeset 7543


Ignore:
Timestamp:
Dec 30, 2008, 3:29:09 AM (12 years ago)
Author:
charles
Message:

(trunk libT) eliminate a couple more unnecessary malloc() + free() pairs

Location:
trunk/libtransmission
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/fdlimit.c

    r7439 r7543  
    262262                   uint64_t     desiredFileSize )
    263263{
    264     int                  i, winner = -1;
     264    int i, winner = -1;
    265265    struct tr_openfile * o;
    266     char               * filename;
     266    char filename[MAX_PATH_LENGTH];
    267267
    268268    assert( folder && *folder );
     
    270270    assert( doWrite == 0 || doWrite == 1 );
    271271
    272     filename = tr_buildPath( folder, torrentFile, NULL );
    273     dbgmsg( "looking for file '%s', writable %c", filename,
    274             doWrite ? 'y' : 'n' );
     272    tr_snprintf( filename, sizeof( filename ), "%s%c%s", folder, TR_PATH_DELIMITER, torrentFile );
     273    dbgmsg( "looking for file '%s', writable %c", filename, doWrite ? 'y' : 'n' );
    275274
    276275    tr_lockLock( gFd->lock );
     
    362361        if( err ) {
    363362            tr_lockUnlock( gFd->lock );
    364             tr_free( filename );
    365363            errno = err;
    366364            return -1;
     
    377375    o->closeWhenDone = 0;
    378376    o->date = tr_date( );
    379     tr_free( filename );
    380377    tr_lockUnlock( gFd->lock );
    381378    return o->fd;
  • trunk/libtransmission/inout.c

    r7531 r7543  
    7474
    7575    typedef size_t ( *iofunc )( int, void *, size_t );
    76     iofunc          func = ioMode ==
    77                            TR_IO_READ ? (iofunc)read : (iofunc)write;
    78     char          * path;
     76    iofunc          func = ioMode == TR_IO_READ ? (iofunc)read : (iofunc)write;
    7977    struct stat     sb;
    8078    int             fd = -1;
     
    8785    assert( fileOffset + buflen <= file->length );
    8886
    89     path = tr_buildPath( tor->downloadDir, file->name, NULL );
    90     fileExists = !stat( path, &sb );
    91     tr_free( path );
     87    {
     88        char path[MAX_PATH_LENGTH];
     89        tr_snprintf( path, sizeof( path ), "%s%c%s", tor->downloadDir, TR_PATH_DELIMITER, file->name );
     90        fileExists = !stat( path, &sb );
     91    }
    9292
    9393    if( !file->length )
  • trunk/libtransmission/platform.h

    r7535 r7543  
    3737 #define MAX_PATH_LENGTH  MAX_PATH
    3838#else
    39  #define MAX_PATH_LENGTH  1024
     39 #define MAX_PATH_LENGTH  2048
    4040#endif
    4141
  • trunk/libtransmission/utils.c

    r7539 r7543  
    679679
    680680char*
    681 tr_strdup_printf( const char * fmt,
    682                   ... )
     681tr_strdup_printf( const char * fmt, ... )
    683682{
    684683    char *            ret = NULL;
Note: See TracChangeset for help on using the changeset viewer.