From c0fa9c5e9da8ca1a36b4c23b8bf6ebb7cf25d228 Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Tue, 24 Nov 2009 18:22:57 +0000 Subject: [PATCH] (trunk libT) fix bitset crash. add bitset.h to the automake file. --- libtransmission/Makefile.am | 1 + libtransmission/bitset.h | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/libtransmission/Makefile.am b/libtransmission/Makefile.am index c98469f1b..c2509ec4a 100644 --- a/libtransmission/Makefile.am +++ b/libtransmission/Makefile.am @@ -63,6 +63,7 @@ noinst_HEADERS = \ bandwidth.h \ bencode.h \ bitfield.h \ + bitset.h \ blocklist.h \ clients.h \ ConvertUTF.h \ diff --git a/libtransmission/bitset.h b/libtransmission/bitset.h index 98d1d5980..28d071b5c 100644 --- a/libtransmission/bitset.h +++ b/libtransmission/bitset.h @@ -17,6 +17,8 @@ #ifndef TR_BITSET_H #define TR_BITSET_H 1 +#include + #include "transmission.h" #include "bitfield.h" @@ -46,8 +48,14 @@ tr_bitsetReserve( tr_bitset * b, size_t size ) { if( b->bitfield.bitCount < size ) { + tr_bitfield * tmp = tr_bitfieldDup( &b->bitfield ); + tr_bitfieldDestruct( &b->bitfield ); 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; if( !b->haveAll ) { b->haveNone = 0; + tr_bitsetReserve( b, i ); ret = tr_bitfieldAdd( &b->bitfield, i ); } return ret;