diff options
| author | 2026-03-17 18:30:10 +0100 | |
|---|---|---|
| committer | 2026-03-17 18:30:37 +0100 | |
| commit | 04930d578e65d560253d0c24af43e0ecd06117c8 (patch) | |
| tree | 6e90f09af0030160dff034bb8e654580779f47a7 /src/u_hash.h | |
| parent | 3eeb6f219e4d32160fa10895b57a8ddfefff5ff7 (diff) | |
Refactor: move some utils from antcc.h to their own headers
Diffstat (limited to 'src/u_hash.h')
| -rw-r--r-- | src/u_hash.h | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/u_hash.h b/src/u_hash.h new file mode 100644 index 0000000..2b54ae6 --- /dev/null +++ b/src/u_hash.h @@ -0,0 +1,23 @@ +#pragma once + +#include <stddef.h> + +static inline size_t +hashs(size_t h, const char *s) +{ + while (*s) h = (unsigned char)*s++ + h*65599; + return h; +} + +static inline size_t +hashb(size_t h, const void *d, size_t n) +{ + const unsigned char *b = d; + while (n--) h = *b++ + h*65599; + return h; +} + +static inline size_t +ptrhash(const void *p) { + return (size_t)p * 2654435761u; +} |