From 7c2ef083677c354596d3ab3ffec65688e8bdc6f4 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 16 Sep 2005 18:40:53 +0000 Subject: [PATCH] Option for bitset memory allocation using malloc as well as pool. --- lib/datastruct/bitset.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/datastruct/bitset.c b/lib/datastruct/bitset.c index ed712a9cb..57fe90d5f 100644 --- a/lib/datastruct/bitset.c +++ b/lib/datastruct/bitset.c @@ -23,12 +23,21 @@ bitset_t bitset_create(struct pool *mem, unsigned num_bits) { unsigned n = (num_bits / BITS_PER_INT) + 2; size_t size = sizeof(int) * n; - unsigned *bs = pool_zalloc(mem, size); + bitset_t bs; + + if (mem) + bs = pool_zalloc(mem, size); + else + bs = dbg_malloc(size); if (!bs) return NULL; *bs = num_bits; + + if (!mem) + bit_clear_all(bs); + return bs; }