mirror of
https://github.com/transmission/transmission
synced 2024-12-25 09:13:06 +00:00
(trunk libT) more heap pruning: avoid an unnecessary evbuffer_new() + evbuffer_free() in tr_peerIoWriteBytes()
This commit is contained in:
parent
2043356876
commit
118ea87fef
1 changed files with 11 additions and 4 deletions
|
@ -1059,10 +1059,17 @@ tr_peerIoWriteBuf( tr_peerIo * io, struct evbuffer * buf, bool isPieceData )
|
|||
void
|
||||
tr_peerIoWriteBytes( tr_peerIo * io, const void * bytes, size_t byteCount, bool isPieceData )
|
||||
{
|
||||
struct evbuffer * buf = evbuffer_new( );
|
||||
evbuffer_add( buf, bytes, byteCount );
|
||||
tr_peerIoWriteBuf( io, buf, isPieceData );
|
||||
evbuffer_free( buf );
|
||||
struct evbuffer_iovec iovec;
|
||||
evbuffer_reserve_space( io->outbuf, byteCount, &iovec, 1 );
|
||||
|
||||
iovec.iov_len = byteCount;
|
||||
if( io->encryption_type == PEER_ENCRYPTION_RC4 )
|
||||
tr_cryptoEncrypt( &io->crypto, iovec.iov_len, bytes, iovec.iov_base );
|
||||
else
|
||||
memcpy( iovec.iov_base, bytes, iovec.iov_len );
|
||||
evbuffer_commit_space( io->outbuf, &iovec, 1 );
|
||||
|
||||
addDatatype( io, byteCount, isPieceData );
|
||||
}
|
||||
|
||||
/***
|
||||
|
|
Loading…
Reference in a new issue