From ace65b453151845bc361f21f3e5b651c35f9f126 Mon Sep 17 00:00:00 2001 From: Jon Santmyer Date: Wed, 22 May 2024 13:00:41 -0400 Subject: massive refactor for mp and organization --- klib/hash.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 klib/hash.h (limited to 'klib/hash.h') diff --git a/klib/hash.h b/klib/hash.h new file mode 100644 index 0000000..03b0f3a --- /dev/null +++ b/klib/hash.h @@ -0,0 +1,18 @@ +#ifndef JOVE_LIB_HASH_H +#define JOVE_LIB_HASH_H 1 + +#include + +static intmax_t +string_hash(const char *str) +{ + /* Hash function courtesy of the following website: + * http://www.cse.yorku.ca/~oz/hash.html*/ + intmax_t r = 5381; + while (*str) { + r = (r * 33) ^ *(str++); + } + return r; +} + +#endif -- cgit v1.2.1