Changeset 2004 for trunk/libtransmission/fdlimit.c
- Timestamp:
- Jun 9, 2007, 3:36:46 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/fdlimit.c
r1763 r2004 68 68 * Local prototypes 69 69 **********************************************************************/ 70 static int OpenFile( int i, c har * folder,char * name, int write );70 static int OpenFile( int i, const char * folder, const char * name, int write ); 71 71 static void CloseFile( int i ); 72 72 … … 85 85 } 86 86 87 gFd = calloc( sizeof( tr_fd_t ), 1);87 gFd = calloc( 1, sizeof( tr_fd_t ) ); 88 88 89 89 /* Init lock and cond */ … … 126 126 * tr_fdFileOpen 127 127 **********************************************************************/ 128 int tr_fdFileOpen( c har * folder,char * name, int write )128 int tr_fdFileOpen( const char * folder, const char * name, int write ) 129 129 { 130 130 int i, winner, ret; … … 242 242 * tr_fdFileClose 243 243 **********************************************************************/ 244 void tr_fdFileClose( c har * folder,char * name )244 void tr_fdFileClose( const char * folder, const char * name ) 245 245 { 246 246 int i; … … 411 411 * 412 412 **********************************************************************/ 413 static int OpenFile( int i, c har * folder,char * name, int write )413 static int OpenFile( int i, const char * folder, const char * name, int write ) 414 414 { 415 415 tr_openFile_t * file = &gFd->open[i]; 416 416 struct stat sb; 417 char * path;417 char path[MAX_PATH_LENGTH]; 418 418 int ret; 419 419 … … 426 426 } 427 427 428 asprintf( &path, "%s/%s", folder, name );428 snprintf( path, sizeof(path), "%s/%s", folder, name ); 429 429 430 430 /* Create subfolders, if any */ … … 443 443 ret = tr_ioErrorFromErrno(); 444 444 tr_err( "Could not create folder '%s'", path ); 445 free( path );446 445 return ret; 447 446 } … … 452 451 { 453 452 tr_err( "Is not a folder: '%s'", path ); 454 free( path );455 453 return TR_ERROR_IO_OTHER; 456 454 } … … 466 464 { 467 465 ret = tr_ioErrorFromErrno(); 468 free( path );469 466 tr_err( "Could not open %s in %s (%d, %d)", name, folder, write, ret ); 470 467 return ret; 471 468 } 472 free( path );473 469 474 470 return TR_OK;
Note: See TracChangeset
for help on using the changeset viewer.