| author | "Tomas Zeman <tomas.zeman@sun.com>" |
| Fri, 19 Oct 2007 11:01:15 +0200 | |
| changeset 0 | eeadadee24f6 |
| permissions | -rw-r--r-- |
| 0 | 1 |
/* Public domain. */ |
2 |
||
3 |
#include "cdb.h" |
|
4 |
||
5 |
uint32 cdb_hashadd(uint32 h,unsigned char c) |
|
6 |
{
|
|
7 |
h += (h << 5); |
|
8 |
return h ^ c; |
|
9 |
} |
|
10 |
||
11 |
uint32 cdb_hash(char *buf,unsigned int len) |
|
12 |
{
|
|
13 |
uint32 h; |
|
14 |
||
15 |
h = CDB_HASHSTART; |
|
16 |
while (len) {
|
|
17 |
h = cdb_hashadd(h,*buf++); |
|
18 |
--len; |
|
19 |
} |
|
20 |
return h; |
|
21 |
} |