diff options
| author | 3gg <3gg@shellblade.net> | 2025-06-27 09:27:53 -0700 |
|---|---|---|
| committer | 3gg <3gg@shellblade.net> | 2025-06-27 09:27:53 -0700 |
| commit | 8e245a6c9a8287178b2d0853dec24f442c52ce95 (patch) | |
| tree | 2728a073f7c9e7babf23aec6df3db20cfdf30e7a /cstring/src | |
| parent | 1cb585ea456d61213ec2f2faa08bfd6a4fa39228 (diff) | |
Remove bsd string dependency
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 | } | ||
