From 23b83214636f0d63cac77cea30f5dc65b7235a90 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 11 Dec 2008 00:39:47 +0000 Subject: [PATCH] (trunk libT) back out the changes for #1580; closing that ticket as invalid --- libtransmission/inout.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/libtransmission/inout.c b/libtransmission/inout.c index d857c8278..83e26ad89 100644 --- a/libtransmission/inout.c +++ b/libtransmission/inout.c @@ -30,8 +30,6 @@ #include "torrent.h" #include "utils.h" -#define TR_HASH_BUFSIZE (64*1024) - /**** ***** Low-level IO functions ****/ @@ -217,15 +215,11 @@ recalculateHash( const tr_torrent * tor, tr_piece_index_t pieceIndex, uint8_t * setme ) { - static uint8_t * buf = NULL; - size_t bytesLeft; + size_t bytesLeft; uint32_t offset = 0; - int success = TRUE; + int success = TRUE; SHA_CTX sha; - if( buf == NULL ) - buf = tr_new( uint8_t, TR_HASH_BUFSIZE ); - assert( tor ); assert( setme ); assert( pieceIndex < tor->info.pieceCount ); @@ -235,7 +229,8 @@ recalculateHash( const tr_torrent * tor, while( bytesLeft ) { - const int len = MIN( bytesLeft, TR_HASH_BUFSIZE ); + uint8_t buf[8192]; + const int len = MIN( bytesLeft, sizeof( buf ) ); success = !tr_ioRead( tor, pieceIndex, offset, len, buf ); if( !success ) break;