diff options
Diffstat (limited to 'cstring/src')
-rw-r--r-- | cstring/src/cstring.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/cstring/src/cstring.c b/cstring/src/cstring.c index 832cb85..e308589 100644 --- a/cstring/src/cstring.c +++ b/cstring/src/cstring.c | |||
@@ -101,3 +101,11 @@ string string_format_size(size_t size) { | |||
101 | .length = length, | 101 | .length = length, |
102 | }; | 102 | }; |
103 | } | 103 | } |
104 | |||
105 | uint64_t cstring_hash(const char* str) { | ||
106 | uint64_t hash = 0; | ||
107 | for (size_t i = 0; i < strlen(str); ++i) { | ||
108 | hash = (uint64_t)str[i] + (hash << 6) + (hash << 16) - hash; | ||
109 | } | ||
110 | return hash; | ||
111 | } | ||