mirror of
https://github.com/transmission/transmission.git
synced 2026-05-08 09:39:08 +01:00
save a little bit of memory per-torrent.
This commit is contained in:
@@ -39,7 +39,7 @@ struct tr_completion_s
|
||||
tr_bitfield_t * pieceBitfield;
|
||||
|
||||
/* a block is complete if and only if we have it */
|
||||
int * completeBlocks;
|
||||
uint16_t * completeBlocks;
|
||||
};
|
||||
|
||||
tr_completion_t * tr_cpInit( tr_torrent_t * tor )
|
||||
@@ -51,7 +51,7 @@ tr_completion_t * tr_cpInit( tr_torrent_t * tor )
|
||||
cp->blockBitfield = tr_bitfieldNew( tor->blockCount );
|
||||
cp->blockDownloaders = tr_new( uint8_t, tor->blockCount );
|
||||
cp->pieceBitfield = tr_bitfieldNew( tor->info.pieceCount );
|
||||
cp->completeBlocks = tr_new( int, tor->info.pieceCount );
|
||||
cp->completeBlocks = tr_new( uint16_t, tor->info.pieceCount );
|
||||
|
||||
tr_cpReset( cp );
|
||||
|
||||
@@ -70,13 +70,11 @@ void tr_cpClose( tr_completion_t * cp )
|
||||
void tr_cpReset( tr_completion_t * cp )
|
||||
{
|
||||
tr_torrent_t * tor = cp->tor;
|
||||
int i;
|
||||
|
||||
tr_bitfieldClear( cp->blockBitfield );
|
||||
memset( cp->blockDownloaders, 0, tor->blockCount );
|
||||
tr_bitfieldClear( cp->pieceBitfield );
|
||||
for( i = 0; i < tor->info.pieceCount; ++i )
|
||||
cp->completeBlocks[i] = 0;
|
||||
memset( cp->completeBlocks, 0, sizeof(uint16_t) * tor->info.pieceCount );
|
||||
}
|
||||
|
||||
int tr_cpPieceHasAllBlocks( const tr_completion_t * cp, int piece )
|
||||
|
||||
@@ -226,7 +226,7 @@ torrentRealInit( tr_handle_t * h,
|
||||
|
||||
tor->pexDisabled = 0;
|
||||
|
||||
/* Block size: usually 16 ko, or less if we have to */
|
||||
/* Block size: usually 16 kib, or less if we have to */
|
||||
tor->blockSize = MIN( tor->info.pieceSize, 1 << 14 );
|
||||
tor->blockCount = ( tor->info.totalSize + tor->blockSize - 1 ) /
|
||||
tor->blockSize;
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
#define VERSION_MAINTENANCE "@VERSION_MAINTENANCE@"
|
||||
#define VERSION_REVISION "@VERSION_REVISION@"
|
||||
#define VERSION_BETA "@VERSION_BETA@"
|
||||
#define SHORT_VERSION_STRING "@VERSION_STRING_SHORT@"
|
||||
#define SHORT_VERSION_STRING "@VERSION_STRING@"
|
||||
#define LONG_VERSION_STRING "@VERSION_STRING_LONG@"
|
||||
|
||||
Reference in New Issue
Block a user