summaryrefslogtreecommitdiffstats
path: root/klib/hash.h
diff options
context:
space:
mode:
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