From 4f0a5e7572a4257894b4bfede42c26d65152609e Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Sat, 13 Aug 2005 21:25:09 +0000 Subject: * strip glib from avahi-core * implement glib memory allocator * add new documentation file MALLOC * initialize pseudo-RNG from /dev/urandom in avahi-daemon * remove some gcc 4.0 warnings * beef up watch system with real timeouts * move GCC __attribute__ macros into its own header avahi-common/gccmacro.h * make use of GCC's sentinel attribute where it make sense * add malloc() implementations that abort on OOM and enable them by default git-svn-id: file:///home/lennart/svn/public/avahi/trunk@308 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe --- avahi-core/hashmap.c | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) (limited to 'avahi-core/hashmap.c') diff --git a/avahi-core/hashmap.c b/avahi-core/hashmap.c index 0c44d4f..24df1f2 100644 --- a/avahi-core/hashmap.c +++ b/avahi-core/hashmap.c @@ -203,7 +203,6 @@ int avahi_hashmap_replace(AvahiHashmap *m, void *key, void *value) { return 0; } - void avahi_hashmap_remove(AvahiHashmap *m, const void *key) { Entry *e; @@ -215,6 +214,18 @@ void avahi_hashmap_remove(AvahiHashmap *m, const void *key) { entry_free(m, e, 0); } +void avahi_hashmap_foreach(AvahiHashmap *m, AvahiHashmapForeachCallback callback, void *userdata) { + Entry *e, *next; + assert(m); + assert(callback); + + for (e = m->entries_list; e; e = next) { + next = e->entries_next; + + callback(e->key, e->value, userdata); + } +} + unsigned avahi_string_hash(const void *data) { const char *p = data; unsigned hash = 0; @@ -231,19 +242,14 @@ int avahi_string_equal(const void *a, const void *b) { return strcmp(p, q) == 0; } -unsigned avahi_domain_hash(const void *data) { - unsigned hash = 0; - const char *s; - - for (;;) { - char c[65]; +unsigned avahi_int_hash(const void *data) { + const int *i = data; + + return (unsigned) *i; +} - if (!avahi_unescape_label(&s, c, sizeof(c))) - return hash; +int avahi_int_equal(const void *a, const void *b) { + const int *_a = a, *_b = b; - if (!c[0]) - continue; - - hash += avahi_string_hash(avahi_strdown(c)); - } + return *_a == *_b; } -- cgit