hash.h (408B)
1 2 // TODO: move hash to it's own file 3 #define FNV_32_PRIME ((u32)0x01000193) 4 5 static inline unsigned int hash_str(const char *str) 6 { 7 unsigned char *s = (unsigned char *)str; /* unsigned string */ 8 unsigned int hval = 0; 9 10 /* 11 * FNV-1a hash each octet in the buffer 12 */ 13 while (*s) { 14 hval ^= (u32)*s++; 15 hval *= FNV_32_PRIME; 16 } 17 18 /* return our new hash value */ 19 return hval; 20 }