Changeset 2069


Ignore:
Timestamp:
Jun 13, 2007, 5:25:55 PM (15 years ago)
Author:
charles
Message:

assertions for floam

Location:
branches/file_selection/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/file_selection/libtransmission/completion.c

    r2066 r2069  
    162162void tr_cpDownloaderRem( tr_completion_t * cp, int block )
    163163{
    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;
    165171    (cp->blockDownloaders[block])--;
    166172    if( !cp->blockDownloaders[block] && !tr_cpBlockIsComplete( cp, block ) )
     
    172178int tr_cpBlockIsComplete( const tr_completion_t * cp, int block )
    173179{
     180    assert( cp != NULL );
     181    assert( 0 <= block );
     182
    174183    return tr_bitfieldHas( cp->blockBitfield, block );
    175184}
     
    177186void tr_cpBlockAdd( tr_completion_t * cp, int block )
    178187{
    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;
    180195
    181196    if( !tr_cpBlockIsComplete( cp, block ) )
     
    196211const tr_bitfield_t * tr_cpBlockBitfield( const tr_completion_t * cp )
    197212{
     213    assert( cp != NULL );
     214
    198215    return cp->blockBitfield;
    199216}
     
    203220{
    204221    int i;
    205     tr_torrent_t * tor = cp->tor;
     222
     223    assert( cp != NULL );
     224    assert( bitfield != NULL );
    206225
    207226    tr_cpReset( cp );
    208     cp->tor = tor;
    209227
    210228    for( i=0; i < cp->tor->blockCount; ++i )
     
    215233float tr_cpPercentBlocksInPiece( const tr_completion_t * cp, int piece )
    216234{
     235    assert( cp != NULL );
     236
    217237    return cp->completeBlocks[piece] / (double)tr_cpCountBlocks( cp, piece );
    218238}
     
    283303tr_cpMissingBlocksForPiece( const tr_completion_t * cp, int piece )
    284304{
     305    assert( cp != NULL );
     306
    285307    return cp->missingBlocks[piece];
    286308}
     
    296318    int i;
    297319    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;
    300326    for( i=0; i<info->pieceCount; ++i ) {
    301327        if( tr_cpPieceIsComplete( cp, i ) )
     
    314340    int i;
    315341    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;
    319350    for( i=0; i<info->pieceCount; ++i )
    320351        if( !tr_cpPieceIsComplete( cp, i ) )
     
    329360    int i;
    330361    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;
    333370
    334371    for( i=0; i<info->pieceCount; ++i )
     
    344381    int i;
    345382    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;
    348389    for( i=0; i<tor->info.pieceCount; ++i )
    349390        have += cp->completeBlocks[ i ];
     
    357398    int i;
    358399    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;
    360406
    361407    for( i=0; i<tor->info.pieceCount; ++i ) {
  • branches/file_selection/libtransmission/peer.c

    r2068 r2069  
    575575
    576576        /* 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 );
    578578        for( i=0; i<peer->inRequestCount; ++i) {
    579579            const tr_request_t * r = &peer->inRequests[i];
Note: See TracChangeset for help on using the changeset viewer.