(trunk libT) #2655: "1.80b1 crash in peer-mgr.c's getPeersToClose()" -- fixed
This commit is contained in:
parent
b739e72f0f
commit
9fb6c5b1c4
|
@ -159,34 +159,29 @@ tr_bitfieldRemRange( tr_bitfield * b,
|
||||||
}
|
}
|
||||||
|
|
||||||
tr_bitfield*
|
tr_bitfield*
|
||||||
tr_bitfieldOr( tr_bitfield * a,
|
tr_bitfieldOr( tr_bitfield * a, const tr_bitfield * b )
|
||||||
const tr_bitfield * b )
|
|
||||||
{
|
{
|
||||||
uint8_t * ait;
|
uint8_t * ait = a->bits;
|
||||||
const uint8_t *aend, *bit, *bend;
|
const uint8_t * aend = ait + a->byteCount;
|
||||||
|
const uint8_t * bit = b->bits;
|
||||||
|
const uint8_t * bend = bit + b->byteCount;
|
||||||
|
|
||||||
for( ait = a->bits, aend = ait + a->byteCount,
|
while( ait!=aend && bit!=bend )
|
||||||
bit = b->bits, bend = bit + b->byteCount;
|
|
||||||
ait != aend && bit != bend; )
|
|
||||||
{
|
|
||||||
*ait++ |= *bit++;
|
*ait++ |= *bit++;
|
||||||
}
|
|
||||||
|
|
||||||
return a;
|
return a;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set 'a' to all the flags that were in 'a' but not 'b' */
|
/* set 'a' to all the flags that were in 'a' but not 'b' */
|
||||||
void
|
void
|
||||||
tr_bitfieldDifference( tr_bitfield * a,
|
tr_bitfieldDifference( tr_bitfield * a, const tr_bitfield * b )
|
||||||
const tr_bitfield * b )
|
|
||||||
{
|
{
|
||||||
uint8_t * ait;
|
uint8_t * ait = a->bits;
|
||||||
const uint8_t *aend, *bit;
|
const uint8_t * aend = ait + a->byteCount;
|
||||||
|
const uint8_t * bit = b->bits;
|
||||||
|
const uint8_t * bend = bit + b->byteCount;
|
||||||
|
|
||||||
assert( a->byteCount == b->byteCount );
|
while( ait!=aend && bit!=bend )
|
||||||
|
|
||||||
for( ait = a->bits, bit = b->bits, aend = ait + a->byteCount;
|
|
||||||
ait != aend; )
|
|
||||||
*ait++ &= ~( *bit++ );
|
*ait++ &= ~( *bit++ );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue