mirror of
git://sourceware.org/git/lvm2.git
synced 2025-03-10 16:58:47 +03:00
Option for bitset memory allocation using malloc as well as pool.
This commit is contained in:
parent
dbb43034e6
commit
7c2ef08367
@ -23,12 +23,21 @@ bitset_t bitset_create(struct pool *mem, unsigned num_bits)
|
|||||||
{
|
{
|
||||||
unsigned n = (num_bits / BITS_PER_INT) + 2;
|
unsigned n = (num_bits / BITS_PER_INT) + 2;
|
||||||
size_t size = sizeof(int) * n;
|
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)
|
if (!bs)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
*bs = num_bits;
|
*bs = num_bits;
|
||||||
|
|
||||||
|
if (!mem)
|
||||||
|
bit_clear_all(bs);
|
||||||
|
|
||||||
return bs;
|
return bs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user