From 04930d578e65d560253d0c24af43e0ecd06117c8 Mon Sep 17 00:00:00 2001 From: lemon Date: Tue, 17 Mar 2026 18:30:10 +0100 Subject: Refactor: move some utils from antcc.h to their own headers --- src/u_hash.h | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/u_hash.h (limited to 'src/u_hash.h') 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 + +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; +} -- cgit v1.2.3