mirror of
https://github.com/transmission/transmission
synced 2025-02-15 19:04:45 +00:00
(trunk libT) #3584 "minor valgrind warning in makemeta.c" -- fixed.
This commit is contained in:
parent
ad613b05f7
commit
0a323ac019
1 changed files with 12 additions and 26 deletions
|
@ -294,39 +294,25 @@ getFileInfo( const char * topFile,
|
||||||
tr_benc * uninitialized_length,
|
tr_benc * uninitialized_length,
|
||||||
tr_benc * uninitialized_path )
|
tr_benc * uninitialized_path )
|
||||||
{
|
{
|
||||||
const char * pch, *prev;
|
size_t offset;
|
||||||
size_t topLen;
|
|
||||||
int n;
|
|
||||||
|
|
||||||
/* get the file size */
|
/* get the file size */
|
||||||
tr_bencInitInt( uninitialized_length, file->size );
|
tr_bencInitInt( uninitialized_length, file->size );
|
||||||
|
|
||||||
/* how much of file->filename to walk past */
|
/* how much of file->filename to walk past */
|
||||||
topLen = strlen( topFile );
|
offset = strlen( topFile );
|
||||||
if( topLen>0 && topFile[topLen-1]!=TR_PATH_DELIMITER )
|
if( offset>0 && topFile[offset-1]!=TR_PATH_DELIMITER )
|
||||||
++topLen; /* +1 for the path delimiter */
|
++offset; /* +1 for the path delimiter */
|
||||||
|
|
||||||
/* build the path list */
|
/* build the path list */
|
||||||
n = 1;
|
tr_bencInitList( uninitialized_path, 0 );
|
||||||
for( pch = file->filename + topLen; *pch; ++pch )
|
if( strlen(file->filename) > offset ) {
|
||||||
if( *pch == TR_PATH_DELIMITER )
|
char * filename = tr_strdup( file->filename + offset );
|
||||||
++n;
|
char * walk = filename;
|
||||||
tr_bencInitList( uninitialized_path, n );
|
const char * token;
|
||||||
for( prev = pch = file->filename + topLen; ; ++pch )
|
while(( token = strsep( &walk, TR_PATH_DELIMITER_STR )))
|
||||||
{
|
tr_bencListAddStr( uninitialized_path, token );
|
||||||
char buf[TR_PATH_MAX];
|
tr_free( filename );
|
||||||
|
|
||||||
if( *pch && *pch != TR_PATH_DELIMITER )
|
|
||||||
continue;
|
|
||||||
|
|
||||||
memcpy( buf, prev, pch - prev );
|
|
||||||
buf[pch - prev] = '\0';
|
|
||||||
|
|
||||||
tr_bencListAddStr( uninitialized_path, buf );
|
|
||||||
|
|
||||||
prev = pch + 1;
|
|
||||||
if( !*pch )
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue