summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-08-28 02:45:06 -0400
committerPaul Duncan <pabs@pablotron.org>2016-08-28 02:45:06 -0400
commitef52728f7e7461cab37ee3cbc3ef9b0d7e328c65 (patch)
tree2da588a094dfdc95cebb75ed0a029dcb0b90aaf0 /hash.c
parent1367fe1bafa1b877f4f92361294eab3a1dd3c11c (diff)
downloadlibfhp-ef52728f7e7461cab37ee3cbc3ef9b0d7e328c65.tar.bz2
libfhp-ef52728f7e7461cab37ee3cbc3ef9b0d7e328c65.zip
add header value parser, fix hashing
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index c35590e..e4bd7c2 100644
--- a/hash.c
+++ b/hash.c
@@ -13,7 +13,7 @@ fhp_hash_init(void) {
uint32_t
fhp_hash_push(uint32_t hash, uint8_t * const buf, size_t len) {
for (size_t i = 0; i < len; i++)
- hash = ((hash << 5) + hash) + buf[len];
+ hash = ((hash << 5) + hash) + buf[i];
return hash;
}
@@ -31,9 +31,9 @@ fhp_lc_hash_push(
size_t len
) {
for (size_t i = 0; i < len; i++) {
- uint8_t c = buf[len];
+ uint8_t c = buf[i];
- if (c >= 'A' && c <= 'Z')
+ if ((c >= 'A') && (c <= 'Z'))
c = (c - 'A') + 'a';
hash = ((hash << 5) + hash) + c;