Commit 36c9d192 authored by Matthias Braun's avatar Matthias Braun
Browse files

bitset size calcuation was broken (uhoh)

[r27418]
parent 8a907f80
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
#include "obst.h" #include "obst.h"
#define BITS_PER_ELEM (sizeof(unsigned) * 8) #define BITS_PER_ELEM (sizeof(unsigned) * 8)
#define BITSET_SIZE_ELEMS(size_bits) ((size_bits)/BITS_PER_ELEM + 1) #define BITSET_SIZE_ELEMS(size_bits) ((size_bits+31)/BITS_PER_ELEM)
#define BITSET_SIZE_BYTES(size_bits) (BITSET_SIZE_ELEMS(size_bits) * sizeof(unsigned)) #define BITSET_SIZE_BYTES(size_bits) (BITSET_SIZE_ELEMS(size_bits) * sizeof(unsigned))
#define BITSET_ELEM(bitset,pos) bitset[pos / BITS_PER_ELEM] #define BITSET_ELEM(bitset,pos) bitset[pos / BITS_PER_ELEM]
...@@ -197,6 +197,9 @@ static inline void rbitset_set_all(unsigned *bitset, unsigned size) ...@@ -197,6 +197,9 @@ static inline void rbitset_set_all(unsigned *bitset, unsigned size)
unsigned i; unsigned i;
unsigned n = BITSET_SIZE_ELEMS(size); unsigned n = BITSET_SIZE_ELEMS(size);
if (n == 0)
return;
for (i = 0; i < n-1; ++i) { for (i = 0; i < n-1; ++i) {
bitset[i] = ~0u; bitset[i] = ~0u;
} }
...@@ -235,7 +238,11 @@ static inline void rbitset_clear_all(unsigned *bitset, unsigned size) ...@@ -235,7 +238,11 @@ static inline void rbitset_clear_all(unsigned *bitset, unsigned size)
static inline void rbitset_flip_all(unsigned *bitset, unsigned size) static inline void rbitset_flip_all(unsigned *bitset, unsigned size)
{ {
unsigned pos; unsigned pos;
unsigned n = BITSET_SIZE_ELEMS(size); unsigned n = BITSET_SIZE_ELEMS(size);
if (n == 0)
return;
for (pos = 0; pos < n-1; ++pos) { for (pos = 0; pos < n-1; ++pos) {
bitset[pos] ^= ~0u; bitset[pos] ^= ~0u;
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment