Ignore:
Timestamp:
Jan 2, 2009, 7:56:06 PM (12 years ago)
Author:
charles
Message:

(trunk libT) avoid some unnecessary memory fragmentation... for composited objects that have a tr_bandwidth, contain the it directly rather than a pointer to one allocated elsewhere on the heap.

File:
1 edited

Legend:

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

    r7578 r7580  
    319319
    320320static tr_peer*
    321 peerConstructor( tr_torrent * tor, const tr_address * addr )
     321peerConstructor( const tr_address * addr )
    322322{
    323323    tr_peer * p;
    324324    p = tr_new0( tr_peer, 1 );
    325325    p->addr = *addr;
    326     p->bandwidth = tr_bandwidthNew( tor->session, tor->bandwidth );
    327326    return p;
    328327}
     
    340339    if( peer == NULL )
    341340    {
    342         peer = peerConstructor( torrent->tor, addr );
     341        peer = peerConstructor( addr );
    343342        tr_ptrArrayInsertSorted( &torrent->peers, peer, peerCompare );
    344343    }
     
    363362    tr_bitfieldFree( peer->blame );
    364363    tr_free( peer->client );
    365 
    366     tr_bandwidthFree( peer->bandwidth );
    367364
    368365    tr_free( peer );
     
    12711268                peer->port = port;
    12721269                peer->io = tr_handshakeStealIO( handshake );
     1270                tr_peerIoSetParent( peer->io, t->tor->bandwidth );
    12731271                tr_peerMsgsNew( t->tor, peer, peerCallbackFunc, t, &peer->msgsTag );
    1274                 tr_peerIoSetBandwidth( io, peer->bandwidth );
    12751272
    12761273                success = TRUE;
     
    13101307        tr_handshake * handshake;
    13111308
    1312         io = tr_peerIoNewIncoming( manager->session, addr, port, socket );
     1309        io = tr_peerIoNewIncoming( manager->session, manager->session->bandwidth, addr, port, socket );
    13131310
    13141311        handshake = tr_handshakeNew( io,
     
    18181815tr_peerGetPieceSpeed( const tr_peer * peer, tr_direction direction )
    18191816{
    1820     assert( peer );
    1821     assert( direction==TR_CLIENT_TO_PEER || direction==TR_PEER_TO_CLIENT );
    1822 
    1823     return tr_bandwidthGetPieceSpeed( peer->bandwidth, direction );
     1817    return peer->io ? tr_peerIoGetPieceSpeed( peer->io, direction ) : 0.0;
    18241818}
    18251819
     
    23162310                   tr_peerIoAddrStr( &atom->addr, atom->port ) );
    23172311
    2318             io = tr_peerIoNewOutgoing( mgr->session, &atom->addr, atom->port, t->hash );
     2312            io = tr_peerIoNewOutgoing( mgr->session, mgr->session->bandwidth, &atom->addr, atom->port, t->hash );
     2313
    23192314            if( io == NULL )
    23202315            {
Note: See TracChangeset for help on using the changeset viewer.