2 * Hash function from http://www.azillionmonkeys.com/qed/hash.html
3 * Copyright (C) 2004-2008 by Paul Hsieh
8 uint32_t sfh_hash(const char * data, int len)
10 uint32_t hash = len, tmp;
13 if (len <= 0 || data == NULL) return 0;
19 for (;len > 0; len--) {
20 hash += sfh_get16(data);
21 tmp = (sfh_get16(data+2) << 11) ^ hash;
22 hash = (hash << 16) ^ tmp;
23 data += 2*sizeof(uint16_t);
27 /* Handle end cases */
29 case 3: hash += sfh_get16(data);
31 hash ^= data[sizeof(uint16_t)] << 18;
34 case 2: hash += sfh_get16(data);
38 case 1: hash += *data;
43 /* Force "avalanching" of final 127 bits */