summaryrefslogtreecommitdiffstats
path: root/klib/hash.h
diff options
context:
space:
mode:
authorJon Santmyer <jon@jonsantmyer.com>2024-05-22 13:00:41 -0400
committerJon Santmyer <jon@jonsantmyer.com>2024-05-22 13:00:41 -0400
commitace65b453151845bc361f21f3e5b651c35f9f126 (patch)
tree262ebd29b0ca1d8584f0b6f1efa7a00d9f4f3e43 /klib/hash.h
parentf004c1ade8d617a82cea2fe249434cccb47a2358 (diff)
downloadjove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.gz
jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.tar.bz2
jove-kernel-ace65b453151845bc361f21f3e5b651c35f9f126.zip
massive refactor for mp and organizationHEADmaster
Diffstat (limited to 'klib/hash.h')
-rw-r--r--klib/hash.h18
1 files changed, 18 insertions, 0 deletions
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 <stdint.h>
+
+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