Fix the handling of size in set_expand.

It was correct for set_add, but not for other ops :/ (out by 1)
This commit is contained in:
Bill Currie 2012-12-07 20:44:09 +09:00
parent 770a40cef0
commit b053edee17

View file

@ -95,7 +95,7 @@ set_expand (set_t *set, unsigned x)
unsigned *map = set->map; unsigned *map = set->map;
size_t size; size_t size;
if (x < set->size) if (x <= set->size)
return; return;
size = (x + BITS) & ~(BITS - 1); size = (x + BITS) & ~(BITS - 1);
@ -111,7 +111,7 @@ static inline void
_set_add (set_t *set, unsigned x) _set_add (set_t *set, unsigned x)
{ {
if (x >= set->size) if (x >= set->size)
set_expand (set, x); set_expand (set, x + 1);
set->map[x / BITS] |= 1 << (x % BITS); set->map[x / BITS] |= 1 << (x % BITS);
} }