/* * return hash function on name. must be compatible with the one * computed a step at a time, elsewhere */ int hashf(const char *name, int len, int hashsize) { int r = 0; while (len--) r = HASHSTEP(r, *name++); return MAKE_POS(r) % hashsize; }
/* * Return a 32-bit hash of the given buffer. The init * value should be 0, or the previous hash value to extend * the previous hash. */ static uint32_t hash32_buf(const void *buf, size_t len, uint32_t hash) { const unsigned char *p = buf; while (len--) hash = HASHSTEP(hash, *p++); return hash; }