aboutsummaryrefslogtreecommitdiff
path: root/util.h
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2021-02-21 19:48:18 +0000
committerDaniel Eklöf <daniel@ekloef.se>2021-02-21 19:48:18 +0000
commit2c881b9f0669e619b462e4b5dd5dc3b6f5a27822 (patch)
tree49776a16394e7aa2f4461e1f1317cf86e9c38500 /util.h
parentMerge branch 'restore-signals-when-spawning-subprocess' (diff)
parentchangelog: OSC-8 support (diff)
Merge branch 'osc8'
Closes #13
Diffstat (limited to 'util.h')
-rw-r--r--util.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/util.h b/util.h
index d2059379..aa9fc8ba 100644
--- a/util.h
+++ b/util.h
@@ -1,5 +1,6 @@
#pragma once
+#include <stdint.h>
#include <threads.h>
#define ALEN(v) (sizeof(v) / sizeof((v)[0]))
@@ -21,3 +22,16 @@ thrd_err_as_string(int thrd_err)
return "unknown error";
}
+
+static inline uint64_t
+sdbm_hash(const char *s)
+{
+ uint64_t hash = 0;
+
+ for (; *s != '\0'; s++) {
+ int c = *s;
+ hash = c + (hash << 6) + (hash << 16) - hash;
+ }
+
+ return hash;
+}