tinycdb-sys 0.0.2

FFI bindings to the TinyCDB C library (http://www.corpit.ru/mjt/tinycdb.html)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/* cdb_hash.c: cdb hashing routine
 *
 * This file is a part of tinycdb package by Michael Tokarev, mjt@corpit.ru.
 * Public domain.
 */

#include "cdb.h"

unsigned
cdb_hash(const void *buf, unsigned len)
{
  register const unsigned char *p = (const unsigned char *)buf;
  register const unsigned char *end = p + len;
  register unsigned hash = 5381;	/* start value */
  while (p < end)
    hash = (hash + (hash << 5)) ^ *p++;
  return hash;
}