diff options
author | quou <quou@disroot.org> | 2024-12-21 21:25:22 +1100 |
---|---|---|
committer | quou <quou@disroot.org> | 2024-12-21 21:25:22 +1100 |
commit | 5bc8f90c38981045515bab04d26687f929f62ec1 (patch) | |
tree | d1d603ded306ae218e75f7eff4b69807f2a14e26 /qstd | |
parent | 3283c6c8c32f980bd01591e441acd9c712c650ef (diff) |
render a triangle
Diffstat (limited to 'qstd')
-rw-r--r-- | qstd/str.c | 9 | ||||
-rw-r--r-- | qstd/str.h | 1 |
2 files changed, 10 insertions, 0 deletions
@@ -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; +} @@ -5,5 +5,6 @@ #include <stdint.h> uint64_t fnv1a64(uint8_t* buf, size_t size); +uint32_t hash_string(const char* s); #endif |