From 5bc8f90c38981045515bab04d26687f929f62ec1 Mon Sep 17 00:00:00 2001 From: quou Date: Sat, 21 Dec 2024 21:25:22 +1100 Subject: render a triangle --- qstd/str.c | 9 +++++++++ qstd/str.h | 1 + 2 files changed, 10 insertions(+) (limited to 'qstd') diff --git a/qstd/str.c b/qstd/str.c index a1c1aa1..b6b0eb7 100644 --- a/qstd/str.c +++ b/qstd/str.c @@ -9,3 +9,12 @@ uint64_t fnv1a64(uint8_t* buf, size_t size) { } return hash; } + +uint32_t hash_string(const char* s) { + uint32_t h = 2166136261u; + for (; *s; s++) { + h ^= *(uint8_t*)s; + h *= 16777619; + } + return h; +} diff --git a/qstd/str.h b/qstd/str.h index f55333e..da9bf36 100644 --- a/qstd/str.h +++ b/qstd/str.h @@ -5,5 +5,6 @@ #include uint64_t fnv1a64(uint8_t* buf, size_t size); +uint32_t hash_string(const char* s); #endif -- cgit v1.2.3-54-g00ecf