diff --git a/server/core/gwbitmask.c b/server/core/gwbitmask.c index 8287bb849..b0cea9758 100644 --- a/server/core/gwbitmask.c +++ b/server/core/gwbitmask.c @@ -109,13 +109,13 @@ bitmask_set(GWBITMASK *bitmask, int bit) unsigned char mask; spinlock_acquire(&bitmask->lock); - if (bit >= bitmask->length) + while (bit >= bitmask->length) { bitmask->bits = realloc(bitmask->bits, (bitmask->length + BIT_LENGTH_INC) / 8); memset(bitmask->bits + (bitmask->length / 8), 0, BIT_LENGTH_INC / 8); - bitmask->length += (BIT_LENGTH_INC / 8); + bitmask->length += BIT_LENGTH_INC; } ptr = bitmask->bits + (bit / 8); mask = 1 << (bit % 8); diff --git a/server/include/gwbitmask.h b/server/include/gwbitmask.h index 6b7b504f1..77c023bd6 100644 --- a/server/include/gwbitmask.h +++ b/server/include/gwbitmask.h @@ -33,8 +33,8 @@ */ /* Both these numbers MUST be exact multiples of 8 */ -#define BIT_LENGTH_INITIAL 32 /**< Initial number of bits in the bitmask */ -#define BIT_LENGTH_INC 32 /**< Number of bits to add on each increment */ +#define BIT_LENGTH_INITIAL 256 /**< Initial number of bits in the bitmask */ +#define BIT_LENGTH_INC 256 /**< Number of bits to add on each increment */ /** * The bitmask structure used to store an arbitrary large bitmask