Changeset 2069
- Timestamp:
- Jun 13, 2007, 5:25:55 PM (15 years ago)
- Location:
- branches/file_selection/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/file_selection/libtransmission/completion.c
r2066 r2069 162 162 void tr_cpDownloaderRem( tr_completion_t * cp, int block ) 163 163 { 164 tr_torrent_t * tor = cp->tor; 164 tr_torrent_t * tor; 165 166 assert( cp != NULL ); 167 assert( cp->tor != NULL ); 168 assert( 0 <= block ); 169 170 tor = cp->tor; 165 171 (cp->blockDownloaders[block])--; 166 172 if( !cp->blockDownloaders[block] && !tr_cpBlockIsComplete( cp, block ) ) … … 172 178 int tr_cpBlockIsComplete( const tr_completion_t * cp, int block ) 173 179 { 180 assert( cp != NULL ); 181 assert( 0 <= block ); 182 174 183 return tr_bitfieldHas( cp->blockBitfield, block ); 175 184 } … … 177 186 void tr_cpBlockAdd( tr_completion_t * cp, int block ) 178 187 { 179 const tr_torrent_t * tor = cp->tor; 188 const tr_torrent_t * tor; 189 190 assert( cp != NULL ); 191 assert( cp->tor != NULL ); 192 assert( 0 <= block ); 193 194 tor = cp->tor; 180 195 181 196 if( !tr_cpBlockIsComplete( cp, block ) ) … … 196 211 const tr_bitfield_t * tr_cpBlockBitfield( const tr_completion_t * cp ) 197 212 { 213 assert( cp != NULL ); 214 198 215 return cp->blockBitfield; 199 216 } … … 203 220 { 204 221 int i; 205 tr_torrent_t * tor = cp->tor; 222 223 assert( cp != NULL ); 224 assert( bitfield != NULL ); 206 225 207 226 tr_cpReset( cp ); 208 cp->tor = tor;209 227 210 228 for( i=0; i < cp->tor->blockCount; ++i ) … … 215 233 float tr_cpPercentBlocksInPiece( const tr_completion_t * cp, int piece ) 216 234 { 235 assert( cp != NULL ); 236 217 237 return cp->completeBlocks[piece] / (double)tr_cpCountBlocks( cp, piece ); 218 238 } … … 283 303 tr_cpMissingBlocksForPiece( const tr_completion_t * cp, int piece ) 284 304 { 305 assert( cp != NULL ); 306 285 307 return cp->missingBlocks[piece]; 286 308 } … … 296 318 int i; 297 319 int ret = CP_COMPLETE; 298 const tr_info_t * info = &cp->tor->info; 299 320 const tr_info_t * info; 321 322 assert( cp != NULL ); 323 assert( cp->tor != NULL ); 324 325 info = &cp->tor->info; 300 326 for( i=0; i<info->pieceCount; ++i ) { 301 327 if( tr_cpPieceIsComplete( cp, i ) ) … … 314 340 int i; 315 341 uint64_t b=0; 316 const tr_torrent_t * tor = cp->tor; 317 const tr_info_t * info = &tor->info; 318 342 const tr_torrent_t * tor; 343 const tr_info_t * info; 344 345 assert( cp != NULL ); 346 assert( cp->tor != NULL ); 347 348 tor = cp->tor; 349 info = &tor->info; 319 350 for( i=0; i<info->pieceCount; ++i ) 320 351 if( !tr_cpPieceIsComplete( cp, i ) ) … … 329 360 int i; 330 361 uint64_t b=0; 331 const tr_torrent_t * tor = cp->tor; 332 const tr_info_t * info = &tor->info; 362 const tr_torrent_t * tor; 363 const tr_info_t * info; 364 365 assert( cp != NULL ); 366 assert( cp->tor != NULL ); 367 368 tor = cp->tor; 369 info = &tor->info; 333 370 334 371 for( i=0; i<info->pieceCount; ++i ) … … 344 381 int i; 345 382 uint64_t have=0; 346 const tr_torrent_t * tor = cp->tor; 347 383 const tr_torrent_t * tor; 384 385 assert( cp != NULL ); 386 assert( cp->tor != NULL ); 387 388 tor = cp->tor; 348 389 for( i=0; i<tor->info.pieceCount; ++i ) 349 390 have += cp->completeBlocks[ i ]; … … 357 398 int i; 358 399 uint64_t have=0, total=0; 359 const tr_torrent_t * tor = cp->tor; 400 const tr_torrent_t * tor; 401 402 assert( cp != NULL ); 403 assert( cp->tor != NULL ); 404 405 tor = cp->tor; 360 406 361 407 for( i=0; i<tor->info.pieceCount; ++i ) { -
branches/file_selection/libtransmission/peer.c
r2068 r2069 575 575 576 576 /* TODO: add some asserts to see if this bitfield is really necessary */ 577 tr_bitfield_t * blocksAlreadyRequested = tr_bitfieldNew( tor-> info.blockCount );577 tr_bitfield_t * blocksAlreadyRequested = tr_bitfieldNew( tor->blockCount ); 578 578 for( i=0; i<peer->inRequestCount; ++i) { 579 579 const tr_request_t * r = &peer->inRequests[i];
Note: See TracChangeset
for help on using the changeset viewer.