chiark / gitweb /
cdbmodule.c: Fix deallocation.
[python-cdb] / src / cdb_hash.c
CommitLineData
dc7ddb87
MW
1/* Public domain. */
2/* Adapted from DJB's original cdb-0.75 package */
3
4#include "cdb.h"
5
6uint32 cdb_hashadd(uint32 h,unsigned char c)
7{
8 h += (h << 5);
9 return h ^ c;
10}
11
12uint32 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}