diff options
author | Alasdair Kergon <agk@redhat.com> | 2010-09-30 21:06:50 +0000 |
---|---|---|
committer | Alasdair Kergon <agk@redhat.com> | 2010-09-30 21:06:50 +0000 |
commit | ac0252ca07e3be5bbb439c913d71c43f551e30ce (patch) | |
tree | 45d08af849560161cd6570fa0ff123cc770f1a70 /libdm/datastruct | |
parent | 0ca1492ca52365cc86aeaf623e370290446ba16f (diff) | |
download | lvm2-ac0252ca07e3be5bbb439c913d71c43f551e30ce.tar.gz |
Add dm_zalloc and use it and dm_pool_zalloc throughout.
Diffstat (limited to 'libdm/datastruct')
-rw-r--r-- | libdm/datastruct/bitset.c | 4 | ||||
-rw-r--r-- | libdm/datastruct/hash.c | 10 |
2 files changed, 5 insertions, 9 deletions
diff --git a/libdm/datastruct/bitset.c b/libdm/datastruct/bitset.c index 563f684e15..5cd8e385a 100644 --- a/libdm/datastruct/bitset.c +++ b/libdm/datastruct/bitset.c @@ -26,8 +26,8 @@ dm_bitset_t dm_bitset_create(struct dm_pool *mem, unsigned num_bits) if (mem) bs = dm_pool_zalloc(mem, size); - else if ((bs = dm_malloc(size))) - memset(bs, 0, size); + else + bs = dm_zalloc(size); if (!bs) return NULL; diff --git a/libdm/datastruct/hash.c b/libdm/datastruct/hash.c index cd722cd81..d4543df5b 100644 --- a/libdm/datastruct/hash.c +++ b/libdm/datastruct/hash.c @@ -90,14 +90,10 @@ struct dm_hash_table *dm_hash_create(unsigned size_hint) { size_t len; unsigned new_size = 16u; - struct dm_hash_table *hc = dm_malloc(sizeof(*hc)); + struct dm_hash_table *hc = dm_zalloc(sizeof(*hc)); - if (!hc) { - stack; - return 0; - } - - memset(hc, 0, sizeof(*hc)); + if (!hc) + return_0; /* round size hint up to a power of two */ while (new_size < size_hint) |