From b3813000e961dff82bd98815ecae95a0a28e5645 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Sat, 11 Apr 2009 15:48:58 +0000 Subject: [PATCH] (trunk libT) add more tests to verify r8214 --- libtransmission/torrent.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libtransmission/torrent.c b/libtransmission/torrent.c index 4cef980c6..e7f6ea884 100644 --- a/libtransmission/torrent.c +++ b/libtransmission/torrent.c @@ -403,12 +403,11 @@ tr_torrentInitFilePieces( tr_torrent * tor ) /* build the array of first-file hints to give calculatePiecePriority */ firstFiles = tr_new( int, inf->pieceCount ); for( p=f=0; ppieceCount; ++p ) { - if( inf->files[f].lastPiece < p ) + while( inf->files[f].lastPiece < p ) ++f; firstFiles[p] = f; } - #if 0 /* test to confirm the first-file hints are correct */ for( p=0; ppieceCount; ++p ) { @@ -417,6 +416,10 @@ tr_torrentInitFilePieces( tr_torrent * tor ) assert( inf->files[f].lastPiece >= p ); if( f > 0 ) assert( inf->files[f-1].lastPiece < p ); + for( f=0; ffileCount; ++f ) + if( pieceHasFile( p, &inf->files[f] ) ) + break; + assert( (int)f == firstFiles[p] ); } #endif