Changeset 12283


Ignore:
Timestamp:
Mar 31, 2011, 8:26:43 PM (11 years ago)
Author:
jordan
Message:

(trunk libT) announcer.c: fold the tiers and trackers into fewer mallocs/frees

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/announcer.c

    r12271 r12283  
    217217}
    218218
    219 static tr_tracker*
    220 trackerNew( const char * announce, const char * scrape, uint32_t id )
    221 {
    222     tr_tracker * tracker = tr_new0( tr_tracker, 1 );
    223     tracker->key = getKey( announce );
    224     tracker->announce = tr_strdup( announce );
    225     tracker->scrape = tr_strdup( scrape );
    226     tracker->id = id;
     219static void
     220trackerConstruct( tr_tracker * tracker, const tr_tracker_info * inf )
     221{
     222    memset( tracker, 0, sizeof( tr_tracker ) );
     223    tracker->key = getKey( inf->announce );
     224    tracker->announce = tr_strdup( inf->announce );
     225    tracker->scrape = tr_strdup( inf->scrape );
     226    tracker->id = inf->id;
    227227    tracker->seederCount = -1;
    228228    tracker->leecherCount = -1;
    229229    tracker->downloadCount = -1;
    230     return tracker;
    231 }
    232 
    233 static void
    234 trackerFree( void * vtracker )
    235 {
    236     tr_tracker * tracker = vtracker;
    237 
     230}
     231
     232static void
     233trackerDestruct( tr_tracker * tracker )
     234{
    238235    tr_free( tracker->tracker_id_str );
    239236    tr_free( tracker->scrape );
    240237    tr_free( tracker->announce );
    241238    tr_free( tracker->key );
    242     tr_free( tracker );
    243239}
    244240
     
    256252    uint64_t byteCounts[3];
    257253
    258     tr_ptrArray trackers; /* tr_tracker */
     254    tr_tracker * trackers;
     255    int tracker_count;
    259256    tr_tracker * currentTracker;
    260257    int currentTrackerIndex;
     
    298295tr_tier;
    299296
    300 static tr_tier *
    301 tierNew( tr_torrent * tor )
    302 {
    303     tr_tier * t;
     297static void
     298tierConstruct( tr_tier * tier, tr_torrent * tor )
     299{
    304300    static int nextKey = 1;
    305301    const time_t now = tr_time( );
    306302
    307     t = tr_new0( tr_tier, 1 );
    308     t->key = nextKey++;
    309     t->announce_events = NULL;
    310     t->announce_event_count = 0;
    311     t->announce_event_alloc = 0;
    312     t->trackers = TR_PTR_ARRAY_INIT;
    313     t->currentTracker = NULL;
    314     t->currentTrackerIndex = -1;
    315     t->scrapeIntervalSec = DEFAULT_SCRAPE_INTERVAL_SEC;
    316     t->announceIntervalSec = DEFAULT_ANNOUNCE_INTERVAL_SEC;
    317     t->announceMinIntervalSec = DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC;
    318     t->scrapeAt = now + tr_cryptoWeakRandInt( 60*3 );
    319     t->tor = tor;
    320 
    321     return t;
    322 }
    323 
    324 static void
    325 tierFree( void * vtier )
    326 {
    327     tr_tier * tier = vtier;
    328     tr_ptrArrayDestruct( &tier->trackers, trackerFree );
     303    memset( tier, 0, sizeof( tr_tier ) );
     304
     305    tier->key = nextKey++;
     306    tier->currentTrackerIndex = -1;
     307    tier->scrapeIntervalSec = DEFAULT_SCRAPE_INTERVAL_SEC;
     308    tier->announceIntervalSec = DEFAULT_ANNOUNCE_INTERVAL_SEC;
     309    tier->announceMinIntervalSec = DEFAULT_ANNOUNCE_MIN_INTERVAL_SEC;
     310    tier->scrapeAt = now + tr_cryptoWeakRandInt( 60*3 );
     311    tier->tor = tor;
     312}
     313
     314static void
     315tierDestruct( tr_tier * tier )
     316{
    329317    tr_free( tier->announce_events );
    330     tr_free( tier );
    331318}
    332319
     
    345332    const int i = ( tier->currentTracker == NULL )
    346333                ? 0
    347                 : ( tier->currentTrackerIndex + 1 ) % tr_ptrArraySize( &tier->trackers );
    348     tier->currentTracker = tr_ptrArrayNth( &tier->trackers, i );
     334                : ( tier->currentTrackerIndex + 1 ) % tier->tracker_count;
    349335    tier->currentTrackerIndex = i;
     336    tier->currentTracker = &tier->trackers[i];
    350337
    351338    /* reset some of the tier's fields */
     
    359346}
    360347
    361 static void
    362 tierAddTracker( tr_tier    * tier,
    363                 const char * announce,
    364                 const char * scrape,
    365                 uint32_t     id )
    366 {
    367     tr_tracker * tracker = trackerNew( announce, scrape, id );
    368 
    369     tr_ptrArrayAppend( &tier->trackers, tracker );
    370     dbgmsg( tier, "adding tracker %s", announce );
    371 
    372     if( !tier->currentTracker )
    373         tierIncrementTracker( tier );
    374 }
    375 
    376 
    377348/***
    378349****
     
    386357typedef struct tr_torrent_tiers
    387358{
    388     tr_ptrArray tiers; /* tr_tier */
     359    tr_tier * tiers;
     360    int tier_count;
     361
     362    tr_tracker * trackers;
     363    int tracker_count;
     364
    389365    tr_tracker_callback * callback;
    390366    void * callbackData;
     
    395371tiersNew( void )
    396372{
    397     tr_torrent_tiers * tiers = tr_new0( tr_torrent_tiers, 1 );
    398     tiers->tiers = TR_PTR_ARRAY_INIT;
    399     return tiers;
    400 }
    401 
    402 static void
    403 tiersFree( tr_torrent_tiers * tiers )
    404 {
    405     tr_ptrArrayDestruct( &tiers->tiers, tierFree );
    406     tr_free( tiers );
     373    return tr_new0( tr_torrent_tiers, 1 );
     374}
     375
     376static void
     377tiersDestruct( tr_torrent_tiers * tt )
     378{
     379    int i;
     380
     381    for( i=0; i<tt->tracker_count; ++i )
     382        trackerDestruct( &tt->trackers[i] );
     383    tr_free( tt->trackers );
     384
     385    for( i=0; i<tt->tier_count; ++i )
     386        tierDestruct( &tt->tiers[i] );
     387    tr_free( tt->tiers );
     388}
     389
     390static void
     391tiersFree( tr_torrent_tiers * tt )
     392{
     393    tiersDestruct( tt );
     394    tr_free( tt );
    407395}
    408396
     
    420408        {
    421409            int i;
    422             tr_ptrArray * tiers = &tor->tiers->tiers;
    423             const int n = tr_ptrArraySize( tiers );
    424             for( i=0; !tier && i<n; ++i )
    425             {
    426                 tr_tier * tmp = tr_ptrArrayNth( tiers, i );
    427                 if( tmp->key == tierId )
    428                     tier = tmp;
    429             }
     410            tr_torrent_tiers * tt = tor->tiers;
     411
     412            for( i=0; !tier && i<tt->tier_count; ++i )
     413                if( tt->tiers[i].key == tierId )
     414                    tier = &tt->tiers[i];
    430415        }
    431416    }
     
    622607
    623608static void
    624 addTorrentToTier( tr_torrent_tiers * tiers, tr_torrent * tor )
     609addTorrentToTier( tr_torrent_tiers * tt, tr_torrent * tor )
    625610{
    626611    int i, n;
     612    int tier_count;
     613    tr_tier * tier;
    627614    tr_tracker_info * infos = filter_trackers( tor->info.trackers,
    628615                                               tor->info.trackerCount, &n );
    629616
    630     /* build our internal table of tiers... */
    631     if( n > 0 )
    632     {
    633         int tierIndex = -1;
    634         tr_tier * tier = NULL;
    635 
    636         for( i=0; i<n; ++i )
    637         {
    638             const tr_tracker_info * info = &infos[i];
    639 
    640             if( info->tier != tierIndex )
    641                 tier = NULL;
    642 
    643             tierIndex = info->tier;
    644 
    645             if( tier == NULL ) {
    646                 tier = tierNew( tor );
    647                 dbgmsg( tier, "adding tier" );
    648                 tr_ptrArrayAppend( &tiers->tiers, tier );
    649             }
    650 
    651             tierAddTracker( tier, info->announce, info->scrape, info->id );
     617    /* build the array of trackers */
     618    tt->trackers = tr_new0( tr_tracker, n );
     619    tt->tracker_count = n;
     620    for( i=0; i<n; ++i )
     621        trackerConstruct( &tt->trackers[i], &infos[i] );
     622
     623    /* count how many tiers there are */
     624    tier_count = 0;
     625    for( i=0; i<n; ++i )
     626        if( !i || ( infos[i].tier != infos[i-1].tier ) )
     627            ++tier_count;
     628
     629    /* build the array of tiers */
     630    tier = NULL;
     631    tt->tiers = tr_new0( tr_tier, tier_count );
     632    tt->tier_count = 0;
     633    for( i=0; i<n; ++i ) {
     634        if( i && ( infos[i].tier == infos[i-1].tier ) )
     635            ++tier->tracker_count;
     636        else {
     637            tier = &tt->tiers[tt->tier_count++];
     638            tierConstruct( tier, tor );
     639            tier->trackers = &tt->trackers[i];
     640            tier->tracker_count = 1;
     641            tierIncrementTracker( tier );
    652642        }
    653643    }
    654644
     645    /* cleanup */
    655646    tr_free( infos );
    656647}
     
    688679{
    689680    int i;
    690     int n;
    691     const tr_tier ** tiers;
     681    struct tr_torrent_tiers * tt;
    692682
    693683    assert( tr_isTorrent( tor ) );
    694684    assert( tor->tiers != NULL );
    695685
    696     if( !tor->isRunning )
    697         return false;
     686    if( tor->isRunning )
     687        tt = tor->tiers;
    698688
    699689    /* return true if any tier can manual announce */
    700     n = tr_ptrArraySize( &tor->tiers->tiers );
    701     tiers = (const tr_tier**) tr_ptrArrayBase( &tor->tiers->tiers );
    702     for( i=0; i<n; ++i )
    703         if( tierCanManualAnnounce( tiers[i] ) )
     690    for( i=0; tt && i<tt->tier_count; ++i )
     691        if( tierCanManualAnnounce( &tt->tiers[i] ) )
    704692            return true;
    705693
     
    711699{
    712700    int i;
    713     int n;
    714     const tr_torrent_tiers * tiers;
    715701    time_t ret = ~(time_t)0;
    716 
    717     assert( tr_isTorrent( tor ) );
     702    struct tr_torrent_tiers * tt = tor->tiers;
    718703
    719704    /* find the earliest manual announce time from all peers */
    720     tiers = tor->tiers;
    721     n = tr_ptrArraySize( &tiers->tiers );
    722     for( i=0; i<n; ++i ) {
    723         tr_tier * tier = tr_ptrArrayNth( (tr_ptrArray*)&tiers->tiers, i );
    724         if( tier->isRunning )
    725             ret = MIN( ret, tier->manualAnnounceAllowedAt );
    726     }
     705    for( i=0; tt && i<tt->tier_count; ++i )
     706        if( tt->tiers[i].isRunning )
     707            ret = MIN( ret, tt->tiers[i].manualAnnounceAllowedAt );
    727708
    728709    return ret;
     
    825806{
    826807    int i;
    827     int n;
    828     tr_torrent_tiers * tiers;
    829 
    830     assert( tr_isTorrent( tor ) );
     808    struct tr_torrent_tiers * tt = tor->tiers;
    831809
    832810    /* walk through each tier and tell them to announce */
    833     tiers = tor->tiers;
    834     n = tr_ptrArraySize( &tiers->tiers );
    835     for( i=0; i<n; ++i )
    836     {
    837         tr_tier * tier = tr_ptrArrayNth( &tiers->tiers, i );
    838         tier_announce_event_push( tier, e, announceAt );
    839     }
     811    for( i=0; i<tt->tier_count; ++i )
     812        tier_announce_event_push( &tt->tiers[i], e, announceAt );
    840813}
    841814
     
    873846tr_announcerAddBytes( tr_torrent * tor, int type, uint32_t byteCount )
    874847{
    875     int i, n;
    876     tr_torrent_tiers * tiers;
     848    int i;
     849    struct tr_torrent_tiers * tt = tor->tiers;
    877850
    878851    assert( tr_isTorrent( tor ) );
    879852    assert( type==TR_ANN_UP || type==TR_ANN_DOWN || type==TR_ANN_CORRUPT );
    880853
    881     tiers = tor->tiers;
    882     n = tr_ptrArraySize( &tiers->tiers );
    883     for( i=0; i<n; ++i )
    884     {
    885         tr_tier * tier = tr_ptrArrayNth( &tiers->tiers, i );
    886         tier->byteCounts[ type ] += byteCount;
    887     }
     854    for( i=0; i<tt->tier_count; ++i )
     855        tt->tiers[i].byteCounts[ type ] += byteCount;
    888856}
    889857
     
    919887tr_announcerRemoveTorrent( tr_announcer * announcer, tr_torrent * tor )
    920888{
    921     assert( tr_isTorrent( tor ) );
    922 
    923     if( tor->tiers )
     889    struct tr_torrent_tiers * tt = tor->tiers;
     890
     891    if( tt != NULL )
    924892    {
    925893        int i;
    926         const int n = tr_ptrArraySize( &tor->tiers->tiers );
    927         for( i=0; i<n; ++i )
     894        for( i=0; i<tt->tier_count; ++i )
    928895        {
    929             tr_tier * tier = tr_ptrArrayNth( &tor->tiers->tiers, i );
     896            tr_tier * tier = &tt->tiers[i];
    930897            if( tier->isRunning )
    931898            {
     
    12121179
    12131180static tr_tier *
    1214 find_tier( tr_torrent * tor, const char * url )
     1181find_tier( tr_torrent * tor, const char * scrape )
    12151182{
    12161183    int i;
    1217     const int n = tr_ptrArraySize( &tor->tiers->tiers );
    1218     tr_tier ** tiers = (tr_tier**) tr_ptrArrayBase( &tor->tiers->tiers );
    1219 
    1220     for( i=0; i<n; ++i ) {
    1221         tr_tracker * tracker = tiers[i]->currentTracker;
    1222         if( tracker && !tr_strcmp0( tracker->scrape, url ) )
    1223             return tiers[i];
     1184    struct tr_torrent_tiers * tt = tor->tiers;
     1185
     1186    for( i=0; tt && i<tt->tier_count; ++i ) {
     1187        const tr_tracker * const tracker = tt->tiers[i].currentTracker;
     1188        if( tracker && !tr_strcmp0( scrape, tracker->scrape ) )
     1189            return &tt->tiers[i];
    12241190    }
    12251191
     
    12281194
    12291195static void
    1230 on_scrape_done( const tr_scrape_response  * response,
    1231                 void                      * vsession )
     1196on_scrape_done( const tr_scrape_response  * response, void * vsession )
    12321197{
    12331198    int i;
     
    14531418    tor = NULL;
    14541419    while(( tor = tr_torrentNext( announcer->session, tor ))) {
    1455         if( tor->tiers ) {
    1456             n = tr_ptrArraySize( &tor->tiers->tiers );
    1457             for( i=0; i<n; ++i ) {
    1458                 tr_tier * tier = tr_ptrArrayNth( &tor->tiers->tiers, i );
    1459                 if( tierNeedsToAnnounce( tier, now ) )
    1460                     tr_ptrArrayAppend( &announceMe, tier );
    1461                 else if( tierNeedsToScrape( tier, now ) )
    1462                     tr_ptrArrayAppend( &scrapeMe, tier );
    1463             }
     1420        struct tr_torrent_tiers * tt = tor->tiers;
     1421        for( i=0; tt && i<tt->tier_count; ++i ) {
     1422            tr_tier * tier = &tt->tiers[i];
     1423            if( tierNeedsToAnnounce( tier, now ) )
     1424                tr_ptrArrayAppend( &announceMe, tier );
     1425            else if( tierNeedsToScrape( tier, now ) )
     1426                tr_ptrArrayAppend( &scrapeMe, tier );
    14641427        }
    14651428    }
     
    15231486{
    15241487    int i;
    1525     int n;
    15261488    int out = 0;
    1527     int tierCount;
    15281489    tr_tracker_stat * ret;
     1490    struct tr_torrent_tiers * tt;
    15291491    const time_t now = tr_time( );
    15301492
     
    15321494    assert( tr_torrentIsLocked( torrent ) );
    15331495
    1534     /* count the trackers... */
    1535     tierCount = tr_ptrArraySize( &torrent->tiers->tiers );
    1536     for( i=n=0; i<tierCount; ++i ) {
    1537         const tr_tier * tier = tr_ptrArrayNth( &torrent->tiers->tiers, i );
    1538         n += tr_ptrArraySize( &tier->trackers );
    1539     }
     1496    tt = torrent->tiers;
    15401497
    15411498    /* alloc the stats */
    1542     *setmeTrackerCount = n;
    1543     ret = tr_new0( tr_tracker_stat, n );
     1499    *setmeTrackerCount = tt->tracker_count;
     1500    ret = tr_new0( tr_tracker_stat, tt->tracker_count );
    15441501
    15451502    /* populate the stats */
    1546     tierCount = tr_ptrArraySize( &torrent->tiers->tiers );
    1547     for( i=0; i<tierCount; ++i )
     1503    for( i=0; i<tt->tier_count; ++i )
    15481504    {
    15491505        int j;
    1550         const tr_tier * tier = tr_ptrArrayNth( &torrent->tiers->tiers, i );
    1551         n = tr_ptrArraySize( &tier->trackers );
    1552         for( j=0; j<n; ++j )
     1506        const tr_tier * const tier = &tt->tiers[i];
     1507        for( j=0; j<tier->tracker_count; ++j )
    15531508        {
    1554             const tr_tracker * tracker = tr_ptrArrayNth( (tr_ptrArray*)&tier->trackers, j );
    1555             tr_tracker_stat * st = ret + out++;
     1509            const tr_tracker * const tracker = &tier->trackers[j];
     1510            tr_tracker_stat * st = &ret[out++];
    15561511
    15571512            st->id = tracker->id;
     
    16401595
    16411596static void
    1642 trackerItemCopyAttributes( tr_tracker * t, const tr_tracker * o )
    1643 {
    1644     assert( t != o );
    1645     assert( t != NULL );
    1646     assert( o != NULL );
    1647 
    1648     t->seederCount = o->seederCount;
    1649     t->leecherCount = o->leecherCount;
    1650     t->downloadCount = o->downloadCount;
    1651     t->downloaderCount = o->downloaderCount;
    1652 }
    1653 
    1654 static void
    1655 tierCopyAttributes( tr_tier * t, const tr_tier * o )
    1656 {
    1657     tr_tier bak;
    1658 
    1659     assert( t != NULL );
    1660     assert( o != NULL );
    1661     assert( t != o );
    1662 
    1663     bak = *t;
    1664     *t = *o;
    1665     t->tor = bak.tor;
    1666     t->trackers = bak.trackers;
    1667     t->announce_events = tr_memdup( o->announce_events, sizeof( tr_announce_event ) * o->announce_event_count );
    1668     t->announce_event_count = o->announce_event_count;
    1669     t->announce_event_alloc = o->announce_event_count;
    1670     t->currentTracker = bak.currentTracker;
    1671     t->currentTrackerIndex = bak.currentTrackerIndex;
     1597copy_tier_attributes_impl( struct tr_tier * tgt, int trackerIndex, const tr_tier * src )
     1598{
     1599    const tr_tier keep = *tgt;
     1600
     1601    /* sanity clause */
     1602    assert( trackerIndex < tgt->tracker_count );
     1603    assert( !tr_strcmp0( tgt->trackers[trackerIndex].announce, src->currentTracker->announce ) );
     1604
     1605    /* bitwise copy will handle most of tr_tier's fields... */
     1606    *tgt = *src;
     1607
     1608    /* ...fix the fields that can't be cleanly bitwise-copied */
     1609    tgt->wasCopied = true;
     1610    tgt->trackers = keep.trackers;
     1611    tgt->announce_events = tr_memdup( src->announce_events, sizeof( tr_announce_event ) * src->announce_event_count );
     1612    tgt->announce_event_count = src->announce_event_count;
     1613    tgt->announce_event_alloc = src->announce_event_count;
     1614    tgt->currentTrackerIndex = trackerIndex;
     1615    tgt->currentTracker = &tgt->trackers[trackerIndex];
     1616    tgt->currentTracker->seederCount = src->currentTracker->seederCount;
     1617    tgt->currentTracker->leecherCount = src->currentTracker->leecherCount;
     1618    tgt->currentTracker->downloadCount = src->currentTracker->downloadCount;
     1619    tgt->currentTracker->downloaderCount = src->currentTracker->downloaderCount;
     1620}
     1621
     1622static void
     1623copy_tier_attributes( struct tr_torrent_tiers * tt, const tr_tier * src )
     1624{
     1625    int i, j;
     1626    bool found = false;
     1627
     1628    /* find a tier (if any) which has a match for src->currentTracker */
     1629    for( i=0; !found && i<tt->tier_count; ++i )
     1630        for( j=0; !found && j<tt->tiers[i].tracker_count; ++j )
     1631            if(( found = !tr_strcmp0( src->currentTracker->announce, tt->tiers[i].trackers[j].announce )))
     1632                copy_tier_attributes_impl( &tt->tiers[i], j, src );
    16721633}
    16731634
     
    16751636tr_announcerResetTorrent( tr_announcer * announcer UNUSED, tr_torrent * tor )
    16761637{
    1677     tr_ptrArray oldTiers = TR_PTR_ARRAY_INIT;
    1678 
    1679     /* if we had tiers already, make a backup of them */
    1680     if( tor->tiers != NULL )
    1681     {
    1682         oldTiers = tor->tiers->tiers;
    1683         tor->tiers->tiers = TR_PTR_ARRAY_INIT;
    1684     }
    1685 
    1686     /* create the new tier/tracker structs */
    1687     addTorrentToTier( tor->tiers, tor );
    1688 
    1689     /* if we had tiers already, merge their state into the new structs */
    1690     if( !tr_ptrArrayEmpty( &oldTiers ) )
    1691     {
    1692         int i, in;
    1693         for( i=0, in=tr_ptrArraySize(&oldTiers); i<in; ++i )
    1694         {
    1695             int j, jn;
    1696             const tr_tier * o = tr_ptrArrayNth( &oldTiers, i );
    1697 
    1698             if( o->currentTracker == NULL )
    1699                 continue;
    1700 
    1701             for( j=0, jn=tr_ptrArraySize(&tor->tiers->tiers); j<jn; ++j )
    1702             {
    1703                 int k, kn;
    1704                 tr_tier * t = tr_ptrArrayNth(&tor->tiers->tiers,j);
    1705 
    1706                 for( k=0, kn=tr_ptrArraySize(&t->trackers); k<kn; ++k )
    1707                 {
    1708                     tr_tracker * item = tr_ptrArrayNth(&t->trackers,k);
    1709                     if( strcmp( o->currentTracker->announce, item->announce ) )
    1710                         continue;
    1711                     tierCopyAttributes( t, o );
    1712                     t->currentTracker = item;
    1713                     t->currentTrackerIndex = k;
    1714                     t->wasCopied = true;
    1715                     trackerItemCopyAttributes( item, o->currentTracker );
    1716                     dbgmsg( t, "attributes copied to tier %d, tracker %d"
    1717                                                "from tier %d, tracker %d",
    1718                             i, o->currentTrackerIndex, j, k );
    1719 
    1720                 }
    1721             }
    1722         }
    1723     }
     1638    int i;
     1639    const time_t now = tr_time( );
     1640    struct tr_torrent_tiers * tt = tor->tiers;
     1641    tr_torrent_tiers old = *tt;
     1642
     1643    assert( tt != NULL );
     1644
     1645    /* remove the old tiers / trackers */
     1646    tt->tiers = NULL;
     1647    tt->trackers = NULL;
     1648    tt->tier_count = 0;
     1649    tt->tracker_count = 0;
     1650
     1651    /* create the new tiers / trackers */
     1652    addTorrentToTier( tt, tor );
     1653
     1654    /* copy the old tiers' states into their replacements */
     1655    for( i=0; i<old.tier_count; ++i )
     1656        if( old.tiers[i].currentTracker != NULL )
     1657            copy_tier_attributes( tt, &old.tiers[i] );
    17241658
    17251659    /* kickstart any tiers that didn't get started */
    17261660    if( tor->isRunning )
    1727     {
    1728         int i, n;
    1729         const time_t now = tr_time( );
    1730         tr_tier ** tiers = (tr_tier**) tr_ptrArrayPeek( &tor->tiers->tiers, &n );
    1731         for( i=0; i<n; ++i ) {
    1732             tr_tier * tier = tiers[i];
    1733             if( !tier->wasCopied )
    1734                 tier_announce_event_push( tier, TR_ANNOUNCE_EVENT_STARTED, now );
    1735         }
    1736     }
     1661        for( i=0; i<tt->tier_count; ++i )
     1662            if( !tt->tiers[i].wasCopied )
     1663                tier_announce_event_push( &tt->tiers[i], TR_ANNOUNCE_EVENT_STARTED, now );
    17371664
    17381665    /* cleanup */
    1739     tr_ptrArrayDestruct( &oldTiers, tierFree );
    1740 }
     1666    tiersDestruct( &old );
     1667}
Note: See TracChangeset for help on using the changeset viewer.