Ignore:
Timestamp:
Jan 12, 2006, 6:32:29 PM (15 years ago)
Author:
root
Message:

Update 2005-11-18

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/completion.c

    r3 r5  
    2626{
    2727    tr_completion_t * cp;
    28     int i;
    29 
    30     cp                   = calloc( 1, sizeof( tr_completion_t ) );
     28
     29    cp                   = malloc( sizeof( tr_completion_t ) );
    3130    cp->tor              = tor;
    32     cp->blockBitfield    = calloc( 1, ( tor->blockCount + 7 ) / 8 );
    33     cp->blockDownloaders = calloc( 1, tor->blockCount );
    34     cp->pieceBitfield    = calloc( 1, ( tor->info.pieceCount + 7 ) / 8 );
    35     cp->missingBlocks    = calloc( 1, tor->info.pieceCount * sizeof( int ) );
    36 
    37     for( i = 0; i < tor->info.pieceCount; i++ )
    38     {
    39         cp->missingBlocks[i] = tr_pieceCountBlocks( i );
    40     }
     31    cp->blockBitfield    = malloc( ( tor->blockCount + 7 ) / 8 );
     32    cp->blockDownloaders = malloc( tor->blockCount );
     33    cp->pieceBitfield    = malloc( ( tor->info.pieceCount + 7 ) / 8 );
     34    cp->missingBlocks    = malloc( tor->info.pieceCount * sizeof( int ) );
     35
     36    tr_cpReset( cp );
    4137
    4238    return cp;
     
    5046    free( cp->missingBlocks );
    5147    free( cp );
     48}
     49
     50void tr_cpReset( tr_completion_t * cp )
     51{
     52    tr_torrent_t * tor = cp->tor;
     53    int i;
     54
     55    cp->blockCount = 0;
     56    memset( cp->blockBitfield,    0, ( tor->blockCount + 7 ) / 8 );
     57    memset( cp->blockDownloaders, 0, tor->blockCount );
     58    memset( cp->pieceBitfield,    0, ( tor->info.pieceCount + 7 ) / 8 );
     59    for( i = 0; i < tor->info.pieceCount; i++ )
     60    {
     61        cp->missingBlocks[i] = tr_pieceCountBlocks( i );
     62    }
    5263}
    5364
Note: See TracChangeset for help on using the changeset viewer.