kernel debug: priv can be NULL early on
[minix.git] / lib / libvtreefs / sdbm.c
blob951143b5fe11fd45018acb953aab21d8e69f3afd
1 /* VTreeFS - sdbm.c - by Alen Stojanov and David van Moolenbroek */
3 /*
4 * sdbm - ndbm work-alike hashed database library
5 * based on Per-Aake Larson's Dynamic Hashing algorithms. BIT 18 (1978).
6 * author: oz@nexus.yorku.ca
7 * status: public domain. keep it that way.
9 * hashing routine
12 #include "inc.h"
14 * polynomial conversion ignoring overflows
15 * [this seems to work remarkably well, in fact better
16 * than the ndbm hash function. Replace at your own risk]
17 * use: 65599 nice.
18 * 65587 even better.
20 long sdbm_hash(char *str, int len)
22 unsigned long n = 0;
24 while (len--)
25 n = *str++ + (n << 6) + (n << 16) - n;
27 return n;