From a180698e8a69f45150ef6d939689d5d2e69314f4 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Fri, 27 Jul 2007 23:07:26 +0000 Subject: [PATCH] save a little bit of memory per-torrent. --- libtransmission/completion.c | 8 +++----- libtransmission/torrent.c | 2 +- libtransmission/version.h.in | 2 +- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/libtransmission/completion.c b/libtransmission/completion.c index 1e1b0be84..ce86054a1 100644 --- a/libtransmission/completion.c +++ b/libtransmission/completion.c @@ -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 ) diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index dfd4a4b66..95f8ff0ba 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -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; diff --git a/libtransmission/version.h.in b/libtransmission/version.h.in index e0af7381a..3905b6f92 100644 --- a/libtransmission/version.h.in +++ b/libtransmission/version.h.in @@ -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@"