(trunk libT) blockIteratorNew() was overallocating much more memory than it used.
This commit is contained in:
parent
20e1222078
commit
71864c18e2
|
@ -687,7 +687,7 @@ blockIteratorNew( Torrent * t )
|
||||||
struct tr_blockIterator * i = tr_new0( struct tr_blockIterator, 1 );
|
struct tr_blockIterator * i = tr_new0( struct tr_blockIterator, 1 );
|
||||||
i->t = t;
|
i->t = t;
|
||||||
i->pieces = getPreferredPieces( t, &i->pieceCount );
|
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;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -715,6 +715,8 @@ blockIteratorNext( struct tr_blockIterator * i, tr_block_index_t * setme )
|
||||||
i->blocks[i->blockCount++] = block;
|
i->blocks[i->blockCount++] = block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert( i->blockCount <= tor->blockCountInPiece );
|
||||||
|
|
||||||
if(( found = ( i->blockIndex < i->blockCount )))
|
if(( found = ( i->blockIndex < i->blockCount )))
|
||||||
*setme = i->blocks[i->blockIndex++];
|
*setme = i->blocks[i->blockIndex++];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue