summaryrefslogtreecommitdiff
path: root/src/basic/hashmap.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2015-06-16 14:44:43 +0200
committerMichal Schmidt <mschmidt@redhat.com>2015-06-16 14:44:43 +0200
commit9ef41ffeec0a677f0c8006b17e5ff1c8434418a3 (patch)
treeb0f66b97ddf0e13c4cd1240fc0fd7ef6ad618a82 /src/basic/hashmap.c
parentaab723074c368f65aaf2748d0c530ba9a1e6ad3e (diff)
parent8927b1dad2d4a7330174cb924090b4635a2547fb (diff)
Merge pull request #197 from dvdhrm/hashmap
hashmap: fix iterators to not skip entries
Diffstat (limited to 'src/basic/hashmap.c')
-rw-r--r--src/basic/hashmap.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/src/basic/hashmap.c b/src/basic/hashmap.c
index 20d599d04b..0ee2f3bd31 100644
--- a/src/basic/hashmap.c
+++ b/src/basic/hashmap.c
@@ -733,29 +733,33 @@ static unsigned hashmap_iterate_entry(HashmapBase *h, Iterator *i) {
: hashmap_iterate_in_internal_order(h, i);
}
-void *internal_hashmap_iterate(HashmapBase *h, Iterator *i, const void **key) {
+bool internal_hashmap_iterate(HashmapBase *h, Iterator *i, void **value, const void **key) {
struct hashmap_base_entry *e;
void *data;
unsigned idx;
idx = hashmap_iterate_entry(h, i);
if (idx == IDX_NIL) {
+ if (value)
+ *value = NULL;
if (key)
*key = NULL;
- return NULL;
+ return false;
}
e = bucket_at(h, idx);
data = entry_value(h, e);
+ if (value)
+ *value = data;
if (key)
*key = e->key;
- return data;
+ return true;
}
-void *set_iterate(Set *s, Iterator *i) {
- return internal_hashmap_iterate(HASHMAP_BASE(s), i, NULL);
+bool set_iterate(Set *s, Iterator *i, void **value) {
+ return internal_hashmap_iterate(HASHMAP_BASE(s), i, value, NULL);
}
#define HASHMAP_FOREACH_IDX(idx, h, i) \