summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-10-15 00:36:45 +0200
committerAnthony G. Basile <blueness@gentoo.org>2014-10-25 14:36:13 -0400
commitac2d134b8c27629754463d505b2aaab3c99c71c6 (patch)
tree602410df61a32001e4ee5335b6fe281918e52830 /src/shared
parent3d43ac3b5694f27c4fa84b93c371d49c5adea5a0 (diff)
hashmap: return more information from resize_buckets()
Return 0 if no resize was needed, 1 if successfully resized and negative on error. Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/hashmap.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c
index 537ba9c037..e965167258 100644
--- a/src/shared/hashmap.c
+++ b/src/shared/hashmap.c
@@ -276,7 +276,7 @@ static struct hashmap_entry *hash_scan(Hashmap *h, unsigned hash, const void *ke
return NULL;
}
-static bool resize_buckets(Hashmap *h) {
+static int resize_buckets(Hashmap *h) {
struct hashmap_entry **n, *i;
unsigned m;
uint8_t nkey[HASH_KEY_SIZE];
@@ -284,7 +284,7 @@ static bool resize_buckets(Hashmap *h) {
assert(h);
if (_likely_(h->n_entries*4 < h->n_buckets*3))
- return false;
+ return 0;
/* Increase by four */
m = (h->n_entries+1)*4-1;
@@ -292,7 +292,7 @@ static bool resize_buckets(Hashmap *h) {
/* If we hit OOM we simply risk packed hashmaps... */
n = new0(struct hashmap_entry*, m);
if (!n)
- return false;
+ return -ENOMEM;
/* Let's use a different randomized hash key for the
* extension, so that people cannot guess what we are using
@@ -331,7 +331,7 @@ static bool resize_buckets(Hashmap *h) {
memcpy(h->hash_key, nkey, HASH_KEY_SIZE);
- return true;
+ return 1;
}
static int __hashmap_put(Hashmap *h, const void *key, void *value, unsigned hash) {
@@ -339,7 +339,7 @@ static int __hashmap_put(Hashmap *h, const void *key, void *value, unsigned hash
struct hashmap_entry *e;
- if (resize_buckets(h))
+ if (resize_buckets(h) > 0)
hash = bucket_hash(h, key);
if (h->from_pool)