summaryrefslogtreecommitdiff
path: root/lib/misc.c
blob: 3ea41a5819ac4c2507fa6b3167bc54219a7e48ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/**
 * \file lib/misc.c
 */

#include "system.h"
#include "lib/misc.h"
#include "debug.h"

unsigned int hashFunctionString(const char * string)
{
    /* Jenkins One-at-a-time hash */
    unsigned int hash = 0xe4721b68;

    while (*string != '\0') {
      hash += *string;
      hash += (hash << 10);
      hash ^= (hash >> 6);
      string++;
    }
    hash += (hash << 3);
    hash ^= (hash >> 11);
    hash += (hash << 15);
    return hash;
}