diff options
Diffstat (limited to 'src/hash.h')
| -rw-r--r-- | src/hash.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/hash.h b/src/hash.h new file mode 100644 index 0000000..0fd689b --- /dev/null +++ b/src/hash.h @@ -0,0 +1,11 @@ +#include <stdint.h> + +static uint32_t hash_name(const char *s) { + unsigned long hash = 5381; + int c; + + while ((c = *s++)) + hash = ((hash << 5) + hash) + c; /* hash * 33 + c */ + + return hash; +} |
