[ci] Test Tcl bindings for dragonfly/freebsd
[xapian.git] / xapian-applications / omega / cdb_hash.cc
blob3d815ee37f859dcfeececf5c21690774dd8ed0bb
1 /* $Id: cdb_hash.c,v 1.5 2003/11/03 16:42:41 mjt Exp $
2 * cdb hashing routine
4 * This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
5 * Public domain.
6 */
8 #include <config.h>
10 #include "cdb.h"
12 unsigned
13 cdb_hash(const void *buf, unsigned len)
15 const unsigned char *p = static_cast<const unsigned char *>(buf);
16 const unsigned char *end = p + len;
17 unsigned hash = 5381; /* start value */
18 while (p < end)
19 hash = (hash + (hash << 5)) ^ *p++;
20 return hash;