diff options
author | Lennart Poettering <lennart@poettering.net> | 2005-08-13 21:25:09 +0000 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2005-08-13 21:25:09 +0000 |
commit | 4f0a5e7572a4257894b4bfede42c26d65152609e (patch) | |
tree | 21e3d5ee20716739590e5931859a4c2052161395 /avahi-core/hashmap.c | |
parent | d6d7d3769441b73ffb5b7af34fef823b41e66312 (diff) |
* 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
Diffstat (limited to 'avahi-core/hashmap.c')
-rw-r--r-- | avahi-core/hashmap.c | 34 |
1 files changed, 20 insertions, 14 deletions
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; } |