summaryrefslogtreecommitdiffstats
path: root/src/pulsecore/hashmap.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/pulsecore/hashmap.c')
-rw-r--r--src/pulsecore/hashmap.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/pulsecore/hashmap.c b/src/pulsecore/hashmap.c
index e957c5ba..b549cb1c 100644
--- a/src/pulsecore/hashmap.c
+++ b/src/pulsecore/hashmap.c
@@ -237,6 +237,39 @@ at_end:
return NULL;
}
+void *pa_hashmap_iterate_backwards(pa_hashmap *h, void **state, const void **key) {
+ struct hashmap_entry *e;
+
+ pa_assert(h);
+ pa_assert(state);
+
+ if (*state == (void*) -1)
+ goto at_beginning;
+
+ if (!*state && !h->iterate_list_tail)
+ goto at_beginning;
+
+ e = *state ? *state : h->iterate_list_tail;
+
+ if (e->iterate_previous)
+ *state = e->iterate_previous;
+ else
+ *state = (void*) -1;
+
+ if (key)
+ *key = e->key;
+
+ return e->value;
+
+at_beginning:
+ *state = (void *) -1;
+
+ if (key)
+ *key = NULL;
+
+ return NULL;
+}
+
void* pa_hashmap_first(pa_hashmap *h) {
pa_assert(h);