diff options
author | Lennart Poettering <lennart@poettering.net> | 2007-07-13 23:22:38 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2007-07-13 23:22:38 +0000 |
commit | f2c98d74837e4e98173ef528d25a5f583340fc2c (patch) | |
tree | 9627c76e21587ec5f3199ae793ca8caf50178cc9 | |
parent | 69bfa351ba89f17b22efad95f1dc6f946cf2df20 (diff) |
Make use of static flist for hashmap entry alllocation
git-svn-id: file:///home/lennart/svn/public/pulseaudio/branches/lennart@1519 fefdeb5f-60dc-0310-8127-8f9354f1896f
-rw-r--r-- | src/pulsecore/hashmap.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/pulsecore/hashmap.c b/src/pulsecore/hashmap.c index 818e12bf..450f89ca 100644 --- a/src/pulsecore/hashmap.c +++ b/src/pulsecore/hashmap.c @@ -33,6 +33,7 @@ #include <pulsecore/idxset.h> #include <pulsecore/log.h> +#include <pulsecore/flist.h> #include "hashmap.h" @@ -55,6 +56,8 @@ struct pa_hashmap { pa_compare_func_t compare_func; }; +PA_STATIC_FLIST_DECLARE(entries, 0); + pa_hashmap *pa_hashmap_new(pa_hash_func_t hash_func, pa_compare_func_t compare_func) { pa_hashmap *h; @@ -88,7 +91,9 @@ static void remove(pa_hashmap *h, struct hashmap_entry *e) { h->data[e->hash] = e->bucket_next; } - pa_xfree(e); + if (pa_flist_push(PA_STATIC_FLIST_GET(entries), e) < 0) + pa_xfree(e); + h->n_entries--; } @@ -127,7 +132,9 @@ int pa_hashmap_put(pa_hashmap *h, const void *key, void *value) { if ((e = get(h, hash, key))) return -1; - e = pa_xnew(struct hashmap_entry, 1); + if (!(e = pa_flist_pop(PA_STATIC_FLIST_GET(entries)))) + e = pa_xnew(struct hashmap_entry, 1); + e->hash = hash; e->key = key; e->value = value; |