Changeset 12387


Ignore:
Timestamp:
Apr 27, 2011, 7:06:06 PM (10 years ago)
Author:
jordan
Message:

(trunk libT) heap pruning: lazy-allocate the array in peer-mgr.c's getPeersToClose().

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-mgr.c

    r12379 r12387  
    32103210{
    32113211    int i, peerCount, outsize;
     3212    struct tr_peer ** ret = NULL;
    32123213    tr_peer ** peers = (tr_peer**) tr_ptrArrayPeek( &t->peers, &peerCount );
    3213     struct tr_peer ** ret = tr_new( tr_peer *, peerCount );
    32143214
    32153215    assert( torrentIsLocked( t ) );
    32163216
    3217     for( i = outsize = 0; i < peerCount; ++i )
    3218         if( shouldPeerBeClosed( t, peers[i], peerCount, now_sec ) )
     3217    for( i = outsize = 0; i < peerCount; ++i ) {
     3218        if( shouldPeerBeClosed( t, peers[i], peerCount, now_sec ) ) {
     3219            if( ret == NULL )
     3220                ret = tr_new( tr_peer *, peerCount );
    32193221            ret[outsize++] = peers[i];
     3222        }
     3223    }
    32203224
    32213225    *setmeSize = outsize;
Note: See TracChangeset for help on using the changeset viewer.