mirror of
https://github.com/transmission/transmission
synced 2024-12-24 08:43:27 +00:00
(trunk) tr_metaInfoBuilderCreate() doesn't need a tr_session* handle anymore
This commit is contained in:
parent
8c372572a2
commit
d1c6956598
6 changed files with 24 additions and 43 deletions
|
@ -331,7 +331,7 @@ main( int argc,
|
|||
if( sourceFile && *sourceFile ) /* creating a torrent */
|
||||
{
|
||||
int err;
|
||||
tr_metainfo_builder * b = tr_metaInfoBuilderCreate( h, sourceFile );
|
||||
tr_metainfo_builder * b = tr_metaInfoBuilderCreate( sourceFile );
|
||||
tr_tracker_info ti;
|
||||
ti.tier = 0;
|
||||
ti.announce = (char*) announce;
|
||||
|
|
|
@ -303,7 +303,7 @@ onSourceActivated( GtkEditable * editable,
|
|||
|
||||
if( ui->builder )
|
||||
tr_metaInfoBuilderFree( ui->builder );
|
||||
ui->builder = tr_metaInfoBuilderCreate( ui->session, filename );
|
||||
ui->builder = tr_metaInfoBuilderCreate( filename );
|
||||
refreshFromBuilder( ui );
|
||||
}
|
||||
|
||||
|
|
|
@ -1234,15 +1234,12 @@ struct jsonWalk
|
|||
static void
|
||||
jsonIndent( struct jsonWalk * data )
|
||||
{
|
||||
int i;
|
||||
char buf[1024], *pch=buf;
|
||||
char buf[1024];
|
||||
const int width = tr_list_size( data->parents ) * 4;
|
||||
|
||||
*pch++ = '\n';
|
||||
for( i=0; i<width; ++i )
|
||||
*pch++ = ' ';
|
||||
|
||||
evbuffer_add( data->out, buf, pch-buf );
|
||||
buf[0] = '\n';
|
||||
memset( buf+1, ' ', width );
|
||||
evbuffer_add( data->out, buf, 1+width );
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -1342,22 +1339,18 @@ static void
|
|||
jsonStringFunc( const tr_benc * val, void * vdata )
|
||||
{
|
||||
struct jsonWalk * data = vdata;
|
||||
const unsigned char *it, *end;
|
||||
const unsigned char * it = (const unsigned char *) val->val.s.s;
|
||||
const unsigned char * end = it + val->val.s.i;
|
||||
|
||||
evbuffer_expand( data->out, val->val.s.i + 2 );
|
||||
evbuffer_add( data->out, "\"", 1 );
|
||||
for( it = (const unsigned char*)val->val.s.s, end = it + val->val.s.i;
|
||||
it != end; ++it )
|
||||
|
||||
for( ; it!=end; ++it )
|
||||
{
|
||||
switch( *it )
|
||||
{
|
||||
case '"':
|
||||
case '\\':
|
||||
case '/':
|
||||
case '\b':
|
||||
case '\f':
|
||||
case '\n':
|
||||
case '\r':
|
||||
case '\t': {
|
||||
case '"': case '\\': case '/': case '\b':
|
||||
case '\f': case '\n': case '\r': case '\t': {
|
||||
char buf[2] = { '\\', *it };
|
||||
evbuffer_add( data->out, buf, 2 );
|
||||
break;
|
||||
|
@ -1365,12 +1358,8 @@ jsonStringFunc( const tr_benc * val, void * vdata )
|
|||
|
||||
default:
|
||||
if( isascii( *it ) )
|
||||
{
|
||||
/*fprintf( stderr, "[%c]\n", *it );*/
|
||||
evbuffer_add( data->out, it, 1 );
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
const UTF8 * tmp = it;
|
||||
UTF32 buf = 0;
|
||||
UTF32 * u32 = &buf;
|
||||
|
@ -1381,7 +1370,6 @@ jsonStringFunc( const tr_benc * val, void * vdata )
|
|||
evbuffer_add_printf( data->out, "\\u%04x", (unsigned int)buf );
|
||||
it = tmp - 1;
|
||||
}
|
||||
/*fprintf( stderr, "[\\u%04x]\n", buf );*/
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -114,8 +114,7 @@ builderFileCompare( const void * va,
|
|||
}
|
||||
|
||||
tr_metainfo_builder*
|
||||
tr_metaInfoBuilderCreate( tr_session * session,
|
||||
const char * topFile )
|
||||
tr_metaInfoBuilderCreate( const char * topFile )
|
||||
{
|
||||
int i;
|
||||
struct FileList * files;
|
||||
|
@ -123,7 +122,7 @@ tr_metaInfoBuilderCreate( tr_session * session,
|
|||
tr_metainfo_builder * ret = tr_new0( tr_metainfo_builder, 1 );
|
||||
|
||||
ret->top = tr_strdup( topFile );
|
||||
ret->handle = session;
|
||||
|
||||
{
|
||||
struct stat sb;
|
||||
stat( topFile, &sb );
|
||||
|
@ -445,29 +444,25 @@ static tr_metainfo_builder * queue = NULL;
|
|||
static tr_thread * workerThread = NULL;
|
||||
|
||||
static tr_lock*
|
||||
getQueueLock( tr_session * session )
|
||||
getQueueLock( void )
|
||||
{
|
||||
static tr_lock * lock = NULL;
|
||||
tr_globalLock( session );
|
||||
|
||||
if( !lock )
|
||||
lock = tr_lockNew( );
|
||||
|
||||
tr_globalUnlock( session );
|
||||
return lock;
|
||||
}
|
||||
|
||||
static void
|
||||
makeMetaWorkerFunc( void * user_data )
|
||||
makeMetaWorkerFunc( void * unused UNUSED )
|
||||
{
|
||||
tr_session * session = user_data;
|
||||
|
||||
for( ; ; )
|
||||
for( ;; )
|
||||
{
|
||||
tr_metainfo_builder * builder = NULL;
|
||||
|
||||
/* find the next builder to process */
|
||||
tr_lock * lock = getQueueLock( session );
|
||||
tr_lock * lock = getQueueLock( );
|
||||
tr_lockLock( lock );
|
||||
if( queue )
|
||||
{
|
||||
|
@ -522,12 +517,12 @@ tr_makeMetaInfo( tr_metainfo_builder * builder,
|
|||
builder->outputFile = tr_strdup_printf( "%s.torrent", builder->top );
|
||||
|
||||
/* enqueue the builder */
|
||||
lock = getQueueLock ( builder->handle );
|
||||
lock = getQueueLock ( );
|
||||
tr_lockLock( lock );
|
||||
builder->nextBuilder = queue;
|
||||
queue = builder;
|
||||
if( !workerThread )
|
||||
workerThread = tr_threadNew( makeMetaWorkerFunc, builder->handle );
|
||||
workerThread = tr_threadNew( makeMetaWorkerFunc, NULL );
|
||||
tr_lockUnlock( lock );
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,6 @@ typedef struct tr_metainfo_builder
|
|||
uint32_t pieceSize;
|
||||
uint32_t pieceCount;
|
||||
int isSingleFile;
|
||||
tr_session * handle;
|
||||
|
||||
/**
|
||||
*** These are set inside tr_makeMetaInfo()
|
||||
|
@ -87,8 +86,7 @@ typedef struct tr_metainfo_builder
|
|||
tr_metainfo_builder;
|
||||
|
||||
|
||||
tr_metainfo_builder*tr_metaInfoBuilderCreate( tr_session * session,
|
||||
const char * topFile );
|
||||
tr_metainfo_builder*tr_metaInfoBuilderCreate( const char * topFile );
|
||||
|
||||
void tr_metaInfoBuilderFree( tr_metainfo_builder* );
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
fStarted = NO;
|
||||
|
||||
fPath = [path retain];
|
||||
fInfo = tr_metaInfoBuilderCreate(handle, [fPath UTF8String]);
|
||||
fInfo = tr_metaInfoBuilderCreate([fPath UTF8String]);
|
||||
|
||||
if (fInfo->fileCount == 0)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue