From 5970eae220cfbaa039fb92699c4d45de9ec410cf Mon Sep 17 00:00:00 2001 From: Julian Daube Date: Wed, 25 Oct 2017 18:38:33 +0200 Subject: [PATCH] rename hash functions to strhash functions --- hashtable.c | 2 +- strhash.c | 6 +++--- strhash.h | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/hashtable.c b/hashtable.c index 2eb87b5..193f6bd 100644 --- a/hashtable.c +++ b/hashtable.c @@ -20,7 +20,7 @@ int key_compare(entry_key_t one, entry_key_t two) { } entry_hash_t key_hash(entry_key_t key) { - return hash_str(key) + 1; // make hash always nonzero + return strhash_str(key) + 1; // make hash always nonzero } hashtable_iterator_t hashtable_end(struct hashtable * table) { diff --git a/strhash.c b/strhash.c index 53f338d..0579d77 100644 --- a/strhash.c +++ b/strhash.c @@ -10,15 +10,15 @@ // use rule: // hash(i) = hash(i - 1) * 33 ^ str[i] // see: http://www.cse.yorku.ca/~oz/hash.html -strhash_t hash_add(strhash_t hash, char c) { +strhash_t strhash_add(strhash_t hash, char c) { return hash * 33 ^ c; } -strhash_t hash_str(const char * str) { +strhash_t strhash_str(const char * str) { strhash_t hash = 0; while(*str) { - hash = hash_add(hash, *str); + hash = strhash_add(hash, *str); str++; } diff --git a/strhash.h b/strhash.h index 7c67f78..0d94e8b 100644 --- a/strhash.h +++ b/strhash.h @@ -13,10 +13,10 @@ typedef size_t strhash_t; // "rehash" string with new char added to end -strhash_t hash_add(strhash_t hash, char c); +strhash_t strhash_add(strhash_t hash, char c); /// hash a given string -strhash_t hash_str(const char * str); +strhash_t strhash_str(const char * str);