(trunk libT) more work on magnet links.

This commit is contained in:
Charles Kerr 2009-11-25 04:12:55 +00:00
parent 7b7dbf58cd
commit 3799fa2ec7
2 changed files with 11 additions and 11 deletions

View File

@ -162,14 +162,15 @@ tr_bitfield*
tr_bitfieldOr( tr_bitfield * a,
const tr_bitfield * b )
{
uint8_t * ait;
const uint8_t *aend, *bit;
uint8_t * ait;
const uint8_t *aend, *bit, *bend;
assert( a->byteCount == b->byteCount );
for( ait = a->bits, bit = b->bits, aend = ait + a->byteCount;
ait != aend; )
for( ait = a->bits, aend = ait + a->byteCount,
bit = b->bits, bend = bit + b->byteCount;
ait != aend && bit != bend; )
{
*ait++ |= *bit++;
}
return a;
}

View File

@ -17,8 +17,6 @@
#ifndef TR_BITSET_H
#define TR_BITSET_H 1
#include <assert.h>
#include "transmission.h"
#include "bitfield.h"
@ -52,8 +50,7 @@ tr_bitsetReserve( tr_bitset * b, size_t size )
tr_bitfieldDestruct( &b->bitfield );
tr_bitfieldConstruct( &b->bitfield, size );
assert( b->bitfield.byteCount >= tmp->byteCount );
memcpy( &b->bitfield.bits, tmp->bits, tmp->byteCount );
memcpy( b->bitfield.bits, tmp->bits, tmp->byteCount );
tr_bitfieldFree( tmp );
}
@ -64,6 +61,7 @@ tr_bitsetHasFast( const tr_bitset * b, const size_t nth )
{
if( b->haveAll ) return TRUE;
if( b->haveNone ) return FALSE;
if( nth >= b->bitfield.bitCount ) return FALSE;
return tr_bitfieldHasFast( &b->bitfield, nth );
}
@ -72,6 +70,7 @@ tr_bitsetHas( const tr_bitset * b, const size_t nth )
{
if( b->haveAll ) return TRUE;
if( b->haveNone ) return FALSE;
if( nth >= b->bitfield.bitCount ) return FALSE;
return tr_bitfieldHas( &b->bitfield, nth );
}
@ -123,7 +122,7 @@ tr_bitsetAdd( tr_bitset * b, int i )
int ret = 0;
if( !b->haveAll ) {
b->haveNone = 0;
tr_bitsetReserve( b, i );
tr_bitsetReserve( b, i+1 );
ret = tr_bitfieldAdd( &b->bitfield, i );
}
return ret;