1 /* VTreeFS - sdbm.c - by Alen Stojanov and David van Moolenbroek */ 2 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. 8 * 9 * hashing routine 10 */ 11 12 #include "inc.h" 13 /* 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. 19 */ 20 long sdbm_hash(char *str, int len) 21 { 22 unsigned long n = 0; 23 24 while (len--) 25 n = *str++ + (n << 6) + (n << 16) - n; 26 27 return n; 28 } 29