summaryrefslogtreecommitdiffstats
path: root/avahi-core/hashmap.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2005-09-25 20:12:40 +0000
committerLennart Poettering <lennart@poettering.net>2005-09-25 20:12:40 +0000
commit1ffedb586bd2fb6daa3970304fac7c5b415cd38f (patch)
treef084dcd2594490b7e95ab026ad2efeaeab3f998a /avahi-core/hashmap.c
parent5867849876e19996fd05a0d4917cb739904519c1 (diff)
* split off lookup.h and publish.h from core.h
* implement wide-area DNS-SD * if multiple clients query the same records, only start the query packet sequence once * implement recursive CNAME queries * add support for resolving services without TXT or A/AAAA records * enlarge resolving timeouts to 5s * implement new browse/resolving events CACHE_EXHAUSTED/ALL_FOR_NOW * add support for resolving services without name. (i.e. for normal SRV records) git-svn-id: file:///home/lennart/svn/public/avahi/trunk@608 941a03a8-eaeb-0310-b9a0-b1bbd8fe43fe
Diffstat (limited to 'avahi-core/hashmap.c')
-rw-r--r--avahi-core/hashmap.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/avahi-core/hashmap.c b/avahi-core/hashmap.c
index 4d2fa3c..24a1249 100644
--- a/avahi-core/hashmap.c
+++ b/avahi-core/hashmap.c
@@ -57,7 +57,7 @@ struct AvahiHashmap {
static Entry* entry_get(AvahiHashmap *m, const void *key) {
unsigned idx;
Entry *e;
-
+
idx = m->hash_func(key) % HASH_MAP_SIZE;
for (e = m->entries[idx]; e; e = e->bucket_next)
@@ -91,7 +91,7 @@ AvahiHashmap* avahi_hashmap_new(AvahiHashFunc hash_func, AvahiEqualFunc equal_fu
assert(hash_func);
assert(equal_func);
- if (!(m = avahi_new(AvahiHashmap, 1)))
+ if (!(m = avahi_new0(AvahiHashmap, 1)))
return NULL;
m->hash_func = hash_func;
@@ -99,8 +99,6 @@ AvahiHashmap* avahi_hashmap_new(AvahiHashFunc hash_func, AvahiEqualFunc equal_fu
m->key_free_func = key_free_func;
m->value_free_func = value_free_func;
- memset(m->entries, 0, sizeof(m->entries));
-
AVAHI_LLIST_HEAD_INIT(Entry, m->entries_list);
return m;
@@ -231,6 +229,8 @@ unsigned avahi_string_hash(const void *data) {
const char *p = data;
unsigned hash = 0;
+ assert(p);
+
for (; *p; p++)
hash = 31 * hash + *p;
@@ -240,17 +240,25 @@ unsigned avahi_string_hash(const void *data) {
int avahi_string_equal(const void *a, const void *b) {
const char *p = a, *q = b;
+ assert(p);
+ assert(q);
+
return strcmp(p, q) == 0;
}
unsigned avahi_int_hash(const void *data) {
const int *i = data;
+ assert(i);
+
return (unsigned) *i;
}
int avahi_int_equal(const void *a, const void *b) {
const int *_a = a, *_b = b;
+ assert(_a);
+ assert(_b);
+
return *_a == *_b;
}