Changeset 12395


Ignore:
Timestamp:
Apr 28, 2011, 5:46:31 PM (12 years ago)
Author:
jordan
Message:

(trunk libT) in peer-mgr.c's refillUpkeep(), allocate the temporary array outside of the loop instead of inside...

File:
1 edited

Legend:

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

    r12387 r12395  
    14441444    time_t too_old;
    14451445    tr_torrent * tor;
     1446    int cancel_buflen = 0;
     1447    struct block_request * cancel = NULL;
    14461448    tr_peerMgr * mgr = vmgr;
    14471449    managerLock( mgr );
     
    14501452    too_old = now - REQUEST_TTL_SECS;
    14511453
     1454    /* alloc the temporary "cancel" buffer */
     1455    tor = NULL;
     1456    while(( tor = tr_torrentNext( mgr->session, tor )))
     1457        cancel_buflen = MAX( cancel_buflen, tor->torrentPeers->requestCount );
     1458    if( cancel_buflen > 0 )
     1459        cancel = tr_new( struct block_request, cancel_buflen );
     1460
     1461    /* prune requests that are too old */
    14521462    tor = NULL;
    14531463    while(( tor = tr_torrentNext( mgr->session, tor )))
     
    14611471            const struct block_request * it;
    14621472            const struct block_request * end;
    1463             struct block_request * cancel = tr_new( struct block_request, n );
    14641473
    14651474            for( it=t->requests, end=it+n; it!=end; ++it )
     
    14901499            for( it=cancel, end=it+cancelCount; it!=end; ++it )
    14911500                pieceListRemoveRequest( t, it->block );
    1492 
    1493             /* cleanup loop */
    1494             tr_free( cancel );
    14951501        }
    14961502    }
    14971503
     1504    tr_free( cancel );
    14981505    tr_timerAddMsec( mgr->refillUpkeepTimer, REFILL_UPKEEP_PERIOD_MSEC );
    14991506    managerUnlock( mgr );
Note: See TracChangeset for help on using the changeset viewer.