Changeset 2348
- Timestamp:
- Jul 15, 2007, 3:52:51 AM (15 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/completion.c
r2316 r2348 116 116 117 117 cp->completeBlocks[piece] = n_blocks; 118 tr_bitfieldAddRange( cp->blockBitfield, startBlock, endBlock -1);118 tr_bitfieldAddRange( cp->blockBitfield, startBlock, endBlock ); 119 119 tr_bitfieldAdd( cp->pieceBitfield, piece ); 120 120 } … … 128 128 129 129 cp->completeBlocks[piece] = 0; 130 tr_bitfieldRemRange ( cp->blockBitfield, startBlock, endBlock -1);130 tr_bitfieldRemRange ( cp->blockBitfield, startBlock, endBlock ); 131 131 tr_bitfieldRem( cp->pieceBitfield, piece ); 132 132 } … … 323 323 b *= tor->blockSize; 324 324 325 if( !tr_cpBlockIsComplete( cp, tor->blockCount - 1 ) )326 b -= (tor->blockSize - (tor->info.totalSize % tor->blockSize));325 if( tor->blockCount && !tr_cpBlockIsComplete( cp, tor->blockCount - 1 ) ) 326 b -= (tor->blockSize - (tor->info.totalSize % tor->blockSize)); 327 327 328 328 return b; … … 349 349 b *= tor->blockSize; 350 350 351 i = tor->blockCount - 1;352 if( !tr_cpBlockIsComplete( cp, tor->blockCount-1 )&& !info->pieces[info->pieceCount-1].dnd )353 b -= (tor->blockSize - (tor->info.totalSize % tor->blockSize));351 if( tor->blockCount && !tr_cpBlockIsComplete( cp, tor->blockCount-1 ) 352 && !info->pieces[info->pieceCount-1].dnd ) 353 b -= (tor->blockSize - (tor->info.totalSize % tor->blockSize)); 354 354 355 355 return b; … … 381 381 uint64_t b = tr_bitfieldCountTrueBits( cp->blockBitfield ) * tor->blockSize; 382 382 383 if( t r_bitfieldHas( cp->blockBitfield, tor->blockCount - 1 ) )383 if( tor->blockCount && tr_bitfieldHas( cp->blockBitfield, tor->blockCount - 1 ) ) 384 384 b -= (tor->blockSize - (tor->info.totalSize % tor->blockSize)); 385 385 -
trunk/libtransmission/fastresume.c
r2328 r2348 301 301 file->name, file->firstPiece, file->lastPiece); 302 302 tr_bitfieldAddRange( uncheckedPieces, 303 file->firstPiece, file->lastPiece );303 file->firstPiece, file->lastPiece+1 ); 304 304 } 305 305 } -
trunk/libtransmission/inout.c
r2328 r2348 223 223 224 224 if( (mode==TR_RECHECK_FORCE) || fastResumeLoad( tor, uncheckedPieces ) ) 225 tr_bitfieldAddRange( uncheckedPieces, 0, tor->info.pieceCount -1);225 tr_bitfieldAddRange( uncheckedPieces, 0, tor->info.pieceCount ); 226 226 227 227 if( tr_bitfieldIsEmpty( uncheckedPieces ) ) { -
trunk/libtransmission/utils.c
r2340 r2348 513 513 void 514 514 tr_bitfieldAddRange( tr_bitfield_t * bitfield, 515 size_t first,516 size_t last)515 size_t begin, 516 size_t end ) 517 517 { 518 518 /* TODO: there are faster ways to do this */ 519 519 unsigned int i; 520 for( i= first; i<=last; ++i )520 for( i=begin; i<end; ++i ) 521 521 tr_bitfieldAdd( bitfield, i ); 522 522 } … … 535 535 void 536 536 tr_bitfieldRemRange ( tr_bitfield_t * b, 537 size_t first,538 size_t last)537 size_t begin, 538 size_t end ) 539 539 { 540 540 /* TODO: there are faster ways to do this */ 541 541 unsigned int i; 542 for( i= first; i<=last; ++i )542 for( i=begin; i<end; ++i ) 543 543 tr_bitfieldRem( b, i ); 544 544 } -
trunk/libtransmission/utils.h
r2341 r2348 190 190 void tr_bitfieldAdd( tr_bitfield_t*, size_t bit ); 191 191 void tr_bitfieldRem( tr_bitfield_t*, size_t bit ); 192 void tr_bitfieldAddRange( tr_bitfield_t *, size_t first, size_t last);193 void tr_bitfieldRemRange ( tr_bitfield_t*, size_t first, size_t last);192 void tr_bitfieldAddRange( tr_bitfield_t *, size_t begin, size_t end ); 193 void tr_bitfieldRemRange ( tr_bitfield_t*, size_t begin, size_t end ); 194 194 195 195 int tr_bitfieldIsEmpty( const tr_bitfield_t* );
Note: See TracChangeset
for help on using the changeset viewer.