diff options
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; } |