(trunk libT) fix bitset crash. add bitset.h to the automake file.
This commit is contained in:
parent
c102f199c3
commit
c0fa9c5e9d
|
@ -63,6 +63,7 @@ noinst_HEADERS = \
|
||||||
bandwidth.h \
|
bandwidth.h \
|
||||||
bencode.h \
|
bencode.h \
|
||||||
bitfield.h \
|
bitfield.h \
|
||||||
|
bitset.h \
|
||||||
blocklist.h \
|
blocklist.h \
|
||||||
clients.h \
|
clients.h \
|
||||||
ConvertUTF.h \
|
ConvertUTF.h \
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
#ifndef TR_BITSET_H
|
#ifndef TR_BITSET_H
|
||||||
#define TR_BITSET_H 1
|
#define TR_BITSET_H 1
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#include "transmission.h"
|
#include "transmission.h"
|
||||||
#include "bitfield.h"
|
#include "bitfield.h"
|
||||||
|
|
||||||
|
@ -46,8 +48,14 @@ tr_bitsetReserve( tr_bitset * b, size_t size )
|
||||||
{
|
{
|
||||||
if( b->bitfield.bitCount < size )
|
if( b->bitfield.bitCount < size )
|
||||||
{
|
{
|
||||||
|
tr_bitfield * tmp = tr_bitfieldDup( &b->bitfield );
|
||||||
|
|
||||||
tr_bitfieldDestruct( &b->bitfield );
|
tr_bitfieldDestruct( &b->bitfield );
|
||||||
tr_bitfieldConstruct( &b->bitfield, size );
|
tr_bitfieldConstruct( &b->bitfield, size );
|
||||||
|
assert( b->bitfield.byteCount >= tmp->byteCount );
|
||||||
|
memcpy( &b->bitfield.bits, tmp->bits, tmp->byteCount );
|
||||||
|
|
||||||
|
tr_bitfieldFree( tmp );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +123,7 @@ tr_bitsetAdd( tr_bitset * b, int i )
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
if( !b->haveAll ) {
|
if( !b->haveAll ) {
|
||||||
b->haveNone = 0;
|
b->haveNone = 0;
|
||||||
|
tr_bitsetReserve( b, i );
|
||||||
ret = tr_bitfieldAdd( &b->bitfield, i );
|
ret = tr_bitfieldAdd( &b->bitfield, i );
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue