diff options
author | Lennart Poettering <lennart@poettering.net> | 2015-10-06 14:02:10 +0300 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2015-10-06 14:02:10 +0300 |
commit | 20d2f7851ac44bd6845d060a952461f5a10e9c87 (patch) | |
tree | 8fd714c7ffa680e3811361d6e5aa7d08f226247d /src/shared/dns-domain.c | |
parent | c48eb61fa72205615e3a2bec9fb6576a5973fc6b (diff) | |
parent | 1e2527a6fede996a429bd44b30a15e76ee293437 (diff) |
Merge pull request #1465 from teg/siphash24
hashmap/siphash24: refactor hash functions
Diffstat (limited to 'src/shared/dns-domain.c')
-rw-r--r-- | src/shared/dns-domain.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c index 6dc04d51e4..5680f01bd9 100644 --- a/src/shared/dns-domain.c +++ b/src/shared/dns-domain.c @@ -379,9 +379,8 @@ int dns_name_concat(const char *a, const char *b, char **_ret) { return 0; } -unsigned long dns_name_hash_func(const void *s, const uint8_t hash_key[HASH_KEY_SIZE]) { +void dns_name_hash_func(const void *s, struct siphash *state) { const char *p = s; - unsigned long ul = hash_key[0]; int r; assert(p); @@ -400,13 +399,17 @@ unsigned long dns_name_hash_func(const void *s, const uint8_t hash_key[HASH_KEY_ if (k > 0) r = k; + if (r == 0) + break; + label[r] = 0; ascii_strlower(label); - ul = ul * hash_key[1] + ul + string_hash_func(label, hash_key); + string_hash_func(label, state); } - return ul; + /* enforce that all names are terminated by the empty label */ + string_hash_func("", state); } int dns_name_compare_func(const void *a, const void *b) { |