summaryrefslogtreecommitdiffstats
path: root/polyp/hashmap.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2004-10-30 01:55:16 +0000
committerLennart Poettering <lennart@poettering.net>2004-10-30 01:55:16 +0000
commit899788b4c5e23af9dabfb98c5f864c2f933804f4 (patch)
treed31b7ae1a90099163e2bd4f6307e84141d49fb02 /polyp/hashmap.c
parent4e5c44de30de40b80354820f8ac1738a9636515a (diff)
some updates for pa_hashmap
add property infrastructure add module module-x11-publish allow ldpreloading of all modules abstract x11wrap from module-x11-bell git-svn-id: file:///home/lennart/svn/public/pulseaudio/trunk@268 fefdeb5f-60dc-0310-8127-8f9354f1896f
Diffstat (limited to 'polyp/hashmap.c')
-rw-r--r--polyp/hashmap.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/polyp/hashmap.c b/polyp/hashmap.c
index 2b9550fd..10b148dd 100644
--- a/polyp/hashmap.c
+++ b/polyp/hashmap.c
@@ -30,6 +30,7 @@
#include "hashmap.h"
#include "idxset.h"
#include "xmalloc.h"
+#include "log.h"
struct hashmap_entry {
struct hashmap_entry *next, *previous, *bucket_next, *bucket_previous;
@@ -147,25 +148,27 @@ void* pa_hashmap_get(struct pa_hashmap *h, const void *key) {
return e->value;
}
-int pa_hashmap_remove(struct pa_hashmap *h, const void *key) {
+void* pa_hashmap_remove(struct pa_hashmap *h, const void *key) {
struct hashmap_entry *e;
unsigned hash;
+ void *data;
assert(h && key);
hash = h->hash_func(key) % h->size;
if (!(e = get(h, hash, key)))
- return 1;
+ return NULL;
+ data = e->value;
remove(h, e);
- return 0;
+ return data;
}
unsigned pa_hashmap_ncontents(struct pa_hashmap *h) {
return h->n_entries;
}
-void *pa_hashmap_iterate(struct pa_hashmap *h, void **state) {
+void *pa_hashmap_iterate(struct pa_hashmap *h, void **state, const void **key) {
assert(h && state);
if (!*state) {
@@ -173,8 +176,14 @@ void *pa_hashmap_iterate(struct pa_hashmap *h, void **state) {
} else
*state = ((struct hashmap_entry*) *state)->next;
- if (!*state)
+ if (!*state) {
+ if (key)
+ *key = NULL;
return NULL;
+ }
+
+ if (key)
+ *key = ((struct hashmap_entry*) *state)->key;
return ((struct hashmap_entry*) *state)->value;
}