chiark
/
gitweb
/
~mdw
/
python-cdb
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
blame
|
history
|
raw
|
HEAD
Debianization patch from upstream.
[python-cdb]
/
src
/
cdb_hash.c
1
/* Public domain. */
2
/* Adapted from DJB's original cdb-0.75 package */
3
4
#include "cdb.h"
5
6
uint32 cdb_hashadd(uint32 h,unsigned char c)
7
{
8
h += (h << 5);
9
return h ^ c;
10
}
11
12
uint32 cdb_hash(char *buf,unsigned int len)
13
{
14
uint32 h;
15
16
h = CDB_HASHSTART;
17
while (len) {
18
h = cdb_hashadd(h,*buf++);
19
--len;
20
}
21
return h;
22
}