etc/services - sync with NetBSD-8
[minix.git] / minix / lib / libvtreefs / sdbm.c
blob3212c856de8e2ae107b3a71b1acc00445119b589
1 /* VTreeFS - sdbm.c - sdbm hash function */
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"
15 * polynomial conversion ignoring overflows
16 * [this seems to work remarkably well, in fact better
17 * than the ndbm hash function. Replace at your own risk]
18 * use: 65599 nice.
19 * 65587 even better.
21 long
22 sdbm_hash(const char *str, int len)
24 unsigned long n = 0;
26 while (len--)
27 n = *str++ + (n << 6) + (n << 16) - n;
29 return n;