(trunk libT) blockIteratorNew() was overallocating much more memory than it used.

This commit is contained in:
Charles Kerr 2008-12-30 21:18:30 +00:00
parent 20e1222078
commit 71864c18e2
1 changed files with 3 additions and 1 deletions

View File

@ -687,7 +687,7 @@ blockIteratorNew( Torrent * t )
struct tr_blockIterator * i = tr_new0( struct tr_blockIterator, 1 );
i->t = t;
i->pieces = getPreferredPieces( t, &i->pieceCount );
i->blocks = tr_new0( tr_block_index_t, t->tor->blockCount );
i->blocks = tr_new0( tr_block_index_t, t->tor->blockCountInPiece );
return i;
}
@ -715,6 +715,8 @@ blockIteratorNext( struct tr_blockIterator * i, tr_block_index_t * setme )
i->blocks[i->blockCount++] = block;
}
assert( i->blockCount <= tor->blockCountInPiece );
if(( found = ( i->blockIndex < i->blockCount )))
*setme = i->blocks[i->blockIndex++];