Ignore:
Timestamp:
Apr 17, 2011, 5:22:50 AM (11 years ago)
Author:
jordan
Message:

(trunk libT) more heap pruning: use composition rather than aggregation for the tr_crypto object owned by tr_peerIo.

File:
1 edited

Legend:

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

    r12343 r12365  
    597597    io->magicNumber = PEER_IO_MAGIC_NUMBER;
    598598    io->refCount = 1;
    599     io->crypto = tr_cryptoNew( torrentHash, isIncoming );
     599    tr_cryptoConstruct( &io->crypto, torrentHash, isIncoming );
    600600    io->session = session;
    601601    io->addr = *addr;
     
    809809    evbuffer_free( io->inbuf );
    810810    io_close_socket( io );
    811     tr_cryptoFree( io->crypto );
     811    tr_cryptoDestruct( &io->crypto );
    812812
    813813    while( io->outbuf_datatypes != NULL )
     
    940940    assert( tr_isPeerIo( io ) );
    941941
    942     tr_cryptoSetTorrentHash( io->crypto, hash );
     942    tr_cryptoSetTorrentHash( &io->crypto, hash );
    943943}
    944944
     
    947947{
    948948    assert( tr_isPeerIo( io ) );
    949     assert( io->crypto );
    950 
    951     return tr_cryptoGetTorrentHash( io->crypto );
     949
     950    return tr_cryptoGetTorrentHash( &io->crypto );
    952951}
    953952
     
    956955{
    957956    assert( tr_isPeerIo( io ) );
    958     assert( io->crypto );
    959 
    960     return tr_cryptoHasTorrentHash( io->crypto );
     957
     958    return tr_cryptoHasTorrentHash( &io->crypto );
    961959}
    962960
     
    966964
    967965void
    968 tr_peerIoSetPeersId( tr_peerIo *     io,
    969                      const uint8_t * peer_id )
     966tr_peerIoSetPeersId( tr_peerIo * io, const uint8_t * peer_id )
    970967{
    971968    assert( tr_isPeerIo( io ) );
     
    10461043        do {
    10471044            evbuffer_peek( buf, -1, &pos, &iovec, 1 );
    1048             tr_cryptoEncrypt( io->crypto, iovec.iov_len, iovec.iov_base, iovec.iov_base );
     1045            tr_cryptoEncrypt( &io->crypto, iovec.iov_len, iovec.iov_base, iovec.iov_base );
    10491046        } while( !evbuffer_ptr_set( buf, &pos, iovec.iov_len, EVBUFFER_PTR_ADD ) );
    10501047    }
     
    11261123        do {
    11271124            evbuffer_peek( outbuf, byteCount, &pos, &iovec, 1 );
    1128             tr_cryptoDecrypt( io->crypto, iovec.iov_len, iovec.iov_base, iovec.iov_base );
     1125            tr_cryptoDecrypt( &io->crypto, iovec.iov_len, iovec.iov_base, iovec.iov_base );
    11291126            byteCount -= iovec.iov_len;
    11301127        } while( !evbuffer_ptr_set( outbuf, &pos, iovec.iov_len, EVBUFFER_PTR_ADD ) );
     
    11461143        case PEER_ENCRYPTION_RC4:
    11471144            evbuffer_remove( inbuf, bytes, byteCount );
    1148             tr_cryptoDecrypt( io->crypto, byteCount, bytes, bytes );
     1145            tr_cryptoDecrypt( &io->crypto, byteCount, bytes, bytes );
    11491146            break;
    11501147
Note: See TracChangeset for help on using the changeset viewer.