From 7ad63f57b6ce7ae9e3cc19dcb441f0a4494fa3f2 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Wed, 15 Oct 2014 00:17:51 +0200 Subject: hashmap: allow hashmap_move() to fail It cannot fail in the current hashmap implementation, but it may fail in alternative implementations (unless a sufficiently large reservation has been placed beforehand). --- src/shared/hashmap.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/shared/hashmap.c') diff --git a/src/shared/hashmap.c b/src/shared/hashmap.c index ebc2ef19bb..6f5f8204dd 100644 --- a/src/shared/hashmap.c +++ b/src/shared/hashmap.c @@ -815,16 +815,16 @@ int hashmap_reserve(Hashmap *h, unsigned entries_add) { return 0; } -void hashmap_move(Hashmap *h, Hashmap *other) { +int hashmap_move(Hashmap *h, Hashmap *other) { struct hashmap_entry *e, *n; assert(h); /* The same as hashmap_merge(), but every new item from other - * is moved to h. This function is guaranteed to succeed. */ + * is moved to h. */ if (!other) - return; + return 0; for (e = other->iterate_list_head; e; e = n) { unsigned h_hash, other_hash; @@ -839,6 +839,8 @@ void hashmap_move(Hashmap *h, Hashmap *other) { unlink_entry(other, e, other_hash); link_entry(h, e, h_hash); } + + return 0; } int hashmap_move_one(Hashmap *h, Hashmap *other, const void *key) { -- cgit v1.2.3-54-g00ecf