*/
static inline unsigned *rbitset_malloc(unsigned size)
{
- unsigned size_bytes = BITSET_SIZE_BYTES(size);
- unsigned *res = xmalloc(size_bytes);
- memset(res, 0, size_bytes);
-
- return res;
+ return XMALLOCNZ(unsigned, BITSET_SIZE_ELEMS(size));
}
/**
#define rbitset_alloca(res, size) \
do { \
unsigned size_bytes = BITSET_SIZE_BYTES(size); \
- res = alloca(size_bytes); \
+ res = (unsigned*)alloca(size_bytes); \
memset(res, 0, size_bytes); \
} while(0)
static inline unsigned *rbitset_obstack_alloc(struct obstack *obst,
unsigned size)
{
- unsigned size_bytes = BITSET_SIZE_BYTES(size);
- unsigned *res = obstack_alloc(obst, size_bytes);
- memset(res, 0, size_bytes);
-
- return res;
-}
-
-/**
- * Allocate an empty raw bitset including the size on an obstack.
- * The size of this bitset can be accessed by bitset[-1].
- *
- * @param obst the obstack where the bitset is allocated on
- * @param size number of bits in the bitset
- *
- * @return the new bitset
- */
-static inline unsigned *rbitset_w_size_obstack_alloc(struct obstack *obst,
- unsigned size)
-{
- unsigned size_bytes = BITSET_SIZE_BYTES(size);
- unsigned *res = obstack_alloc(obst, size_bytes + sizeof(unsigned));
- *res = size;
- ++res;
- memset(res, 0, size_bytes);
-
- return res;
+ return OALLOCNZ(obst, unsigned, BITSET_SIZE_ELEMS(size));
}
-/** Return the size of a bitset allocated with a *_w_size_* function */
-#define rbitset_size(set) (set)[-1]
-
/**
* Duplicate a raw bitset on an obstack.
*
const unsigned *old_bitset, unsigned size)
{
unsigned size_bytes = BITSET_SIZE_BYTES(size);
- unsigned *res = obstack_alloc(obst, size_bytes);
+ unsigned *res = OALLOCN(obst, unsigned, BITSET_SIZE_ELEMS(size));
memcpy(res, old_bitset, size_bytes);
return res;
*/
static inline bool rbitset_is_set(const unsigned *bitset, unsigned pos)
{
- return BITSET_ELEM(bitset, pos) & (1 << (pos % BITS_PER_ELEM));
+ return (BITSET_ELEM(bitset, pos) & (1 << (pos % BITS_PER_ELEM))) != 0;
}
/**