Ignore:
Timestamp:
Apr 2, 2009, 5:30:29 PM (13 years ago)
Author:
charles
Message:

(trunk) modify tr_torrentParse() and tr_torrentNew() arguments s.t. they use the ctor's session instead of passing it in again. Allow a NULL session pointer for some cases of tr_torrentParse().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/torrent.c

    r8097 r8122  
    504504
    505505static void
    506 torrentRealInit( tr_session      * session,
    507                  tr_torrent      * tor,
    508                  const tr_ctor   * ctor )
     506torrentRealInit( tr_torrent * tor, const tr_ctor * ctor )
    509507{
    510508    int          doStart;
     
    514512    static int   nextUniqueId = 1;
    515513    tr_info    * info = &tor->info;
     514    tr_session * session = tr_ctorGetSession( ctor );
     515
     516    assert( session != NULL );
    516517
    517518    tr_globalLock( session );
     
    648649
    649650int
    650 tr_torrentParse( const tr_session  * session,
    651                  const tr_ctor     * ctor,
     651tr_torrentParse( const tr_ctor     * ctor,
    652652                 tr_info           * setmeInfo )
    653653{
     
    656656    tr_info         tmp;
    657657    const tr_benc * metainfo;
     658    tr_session    * session = tr_ctorGetSession( ctor );
    658659
    659660    if( setmeInfo == NULL )
     
    670671        err = TR_EINVALID;
    671672
    672     if( !err && tr_torrentExists( session, setmeInfo->hash ) )
     673    if( !err && session && tr_torrentExists( session, setmeInfo->hash ) )
    673674        err = TR_EDUPLICATE;
    674675
     
    680681
    681682tr_torrent *
    682 tr_torrentNew( tr_session     * session,
    683                const tr_ctor  * ctor,
     683tr_torrentNew( const tr_ctor  * ctor,
    684684               int            * setmeError )
    685685{
     
    688688    tr_torrent * tor = NULL;
    689689
    690     err = tr_torrentParse( session, ctor, &tmpInfo );
     690    assert( ctor != NULL );
     691    assert( tr_isSession( tr_ctorGetSession( ctor ) ) );
     692
     693    err = tr_torrentParse( ctor, &tmpInfo );
    691694    if( !err )
    692695    {
    693696        tor = tr_new0( tr_torrent, 1 );
    694697        tor->info = tmpInfo;
    695         torrentRealInit( session, tor, ctor );
     698        torrentRealInit( tor, ctor );
    696699    }
    697700    else if( setmeError )
Note: See TracChangeset for help on using the changeset viewer.