Ignore:
Timestamp:
Sep 20, 2011, 11:39:40 PM (10 years ago)
Author:
jordan
Message:

#4496 'freeze when having a huge torrent' -- add a bitfield helper function to init the bitfield from an array of flags.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/bitfield.c

    r12554 r12902  
    302302
    303303void
     304tr_bitfieldSetFromFlags( tr_bitfield * b, const bool * flags, size_t n )
     305{
     306    size_t i;
     307    size_t trueCount = 0;
     308
     309    tr_bitfieldFreeArray( b );
     310    tr_bitfieldEnsureBitsAlloced( b, n );
     311
     312    for( i=0; i<n; ++i )
     313    {
     314        if( flags[i] )
     315        {
     316            ++trueCount;
     317            b->bits[i >> 3u] |= ( 0x80 >> ( i & 7u ) );
     318        }
     319    }
     320
     321    tr_bitfieldSetTrueCount( b, trueCount );
     322}
     323
     324void
    304325tr_bitfieldAdd( tr_bitfield * b, size_t nth )
    305326{
Note: See TracChangeset for help on using the changeset viewer.