added rbitset_malloc()
authorMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 18 Nov 2007 20:38:54 +0000 (20:38 +0000)
committerMichael Beck <beck@ipd.info.uni-karlsruhe.de>
Sun, 18 Nov 2007 20:38:54 +0000 (20:38 +0000)
[r16781]

include/libfirm/adt/raw_bitset.h

index 05ac9e4..8ffee7a 100644 (file)
 #define BITSET_SIZE_BYTES(size_bits)    (BITSET_SIZE_ELEMS(size_bits)*4)
 #define BITSET_ELEM(bitset,pos)         bitset[pos / 32]
 
 #define BITSET_SIZE_BYTES(size_bits)    (BITSET_SIZE_ELEMS(size_bits)*4)
 #define BITSET_ELEM(bitset,pos)         bitset[pos / 32]
 
+/**
+ * Allocate an empty raw bitset on the heap.
+ *
+ * @param size  element size of the bitset
+ *
+ * @return the new bitset
+ */
+static INLINE unsigned *rbitset_malloc(unsigned size) {
+       unsigned size_bytes = BITSET_SIZE_BYTES(size);
+       unsigned *res = malloc(size_bytes);
+       memset(res, 0, size_bytes);
+
+       return res;
+}
+
 /**
  * Allocate an empty raw bitset on the stack.
  *
 /**
  * Allocate an empty raw bitset on the stack.
  *