summaryrefslogtreecommitdiff
path: root/lib/rpmhash.c
blob: 34be31354315fd228be9399cd16ea7b0cf96f614 (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/rpmhash.c
 * Hash table implemenation
 */

#include "lib/rpmhash.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;
}