1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
/*
*/
#include "hash.h"
/*
* this is the SDBM hash function from:
* http://en.literateprograms.org/Hash_function_comparison_%28C,_sh%29
*/
hash_t
sdbm_hash (const char * key) {
hash_t h=0;
while(*key) h=*key++ + (h<<6) + (h<<16) - h;
return h;
}
hash_t
s_hash_object (const spointer obj) {
/* We take the address of the pointer. */
hash_t tmp_val = S_POINTER_TO_HASH_T(obj);
/* Scrable it up a bit */
hash_t ret_val = (tmp_val<<6);
ret_val += (ret_val<<16);
return ret_val;
}
|