Fix an out-by-one error in the set operators.

I have no idea why I added that - 1.
This commit is contained in:
Bill Currie 2012-11-06 18:19:46 +09:00
parent 4b64912793
commit 3c79f07705

View file

@ -130,7 +130,7 @@ set_union (set_t *dst, const set_t *src)
unsigned size;
unsigned i;
size = max (dst->size, src->size) - 1;
size = max (dst->size, src->size);
set_expand (dst, size);
for (i = 0; i < src->size / BITS; i++)
dst->map[i] |= src->map[i];
@ -143,7 +143,7 @@ set_intersection (set_t *dst, const set_t *src)
unsigned size;
unsigned i;
size = max (dst->size, src->size) - 1;
size = max (dst->size, src->size);
set_expand (dst, size);
for (i = 0; i < src->size / BITS; i++)
dst->map[i] &= src->map[i];
@ -156,7 +156,7 @@ set_difference (set_t *dst, const set_t *src)
unsigned size;
unsigned i;
size = max (dst->size, src->size) - 1;
size = max (dst->size, src->size);
set_expand (dst, size);
for (i = 0; i < src->size / BITS; i++)
dst->map[i] &= ~src->map[i];
@ -169,7 +169,7 @@ set_assign (set_t *dst, const set_t *src)
unsigned size;
unsigned i;
size = max (dst->size, src->size) - 1;
size = max (dst->size, src->size);
set_expand (dst, size);
for (i = 0; i < src->size / BITS; i++)
dst->map[i] = src->map[i];