summaryrefslogtreecommitdiffstats
path: root/klib/hash.h
blob: 03b0f3a0c6146384d101c2d5d4f89c671af3dd2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef JOVE_LIB_HASH_H
#define JOVE_LIB_HASH_H 1

#include <stdint.h>

static intmax_t
string_hash(const char *str)
{
    /* Hash function courtesy of the following website:
     * http://www.cse.yorku.ca/~oz/hash.html*/
    intmax_t r = 5381;
    while (*str) {
        r = (r * 33) ^ *(str++);
    }
    return r;
}

#endif