Changeset 9562
- Timestamp:
- Nov 25, 2009, 4:12:55 AM (13 years ago)
- Location:
- trunk/libtransmission
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/libtransmission/bitfield.c
r9559 r9562 163 163 const tr_bitfield * b ) 164 164 { 165 uint8_t * 166 const uint8_t *aend, *bit ;167 168 assert( a->byteCount == b->byteCount );169 170 for( ait = a->bits, bit = b->bits, aend = ait + a->byteCount;171 ait != aend; )165 uint8_t * ait; 166 const uint8_t *aend, *bit, *bend; 167 168 for( ait = a->bits, aend = ait + a->byteCount, 169 bit = b->bits, bend = bit + b->byteCount; 170 ait != aend && bit != bend; ) 171 { 172 172 *ait++ |= *bit++; 173 } 173 174 174 175 return a; -
trunk/libtransmission/bitset.h
r9558 r9562 17 17 #ifndef TR_BITSET_H 18 18 #define TR_BITSET_H 1 19 20 #include <assert.h>21 19 22 20 #include "transmission.h" … … 53 51 tr_bitfieldDestruct( &b->bitfield ); 54 52 tr_bitfieldConstruct( &b->bitfield, size ); 55 assert( b->bitfield.byteCount >= tmp->byteCount ); 56 memcpy( &b->bitfield.bits, tmp->bits, tmp->byteCount ); 53 memcpy( b->bitfield.bits, tmp->bits, tmp->byteCount ); 57 54 58 55 tr_bitfieldFree( tmp ); … … 65 62 if( b->haveAll ) return TRUE; 66 63 if( b->haveNone ) return FALSE; 64 if( nth >= b->bitfield.bitCount ) return FALSE; 67 65 return tr_bitfieldHasFast( &b->bitfield, nth ); 68 66 } … … 73 71 if( b->haveAll ) return TRUE; 74 72 if( b->haveNone ) return FALSE; 73 if( nth >= b->bitfield.bitCount ) return FALSE; 75 74 return tr_bitfieldHas( &b->bitfield, nth ); 76 75 } … … 124 123 if( !b->haveAll ) { 125 124 b->haveNone = 0; 126 tr_bitsetReserve( b, i );125 tr_bitsetReserve( b, i+1 ); 127 126 ret = tr_bitfieldAdd( &b->bitfield, i ); 128 127 }
Note: See TracChangeset
for help on using the changeset viewer.