--- libaitcrc/src/hash.c 2010/06/13 16:29:03 1.1.2.1 +++ libaitcrc/src/hash.c 2010/09/28 08:40:53 1.1.2.2 @@ -3,7 +3,7 @@ * by Michael Pounov * * $Author: misho $ -* $Id: hash.c,v 1.1.2.1 2010/06/13 16:29:03 misho Exp $ +* $Id: hash.c,v 1.1.2.2 2010/09/28 08:40:53 misho Exp $ * *************************************************************************/ #include "global.h" @@ -112,6 +112,31 @@ hash_jenkins(const char *csStr, int nStrLen) hash += (hash << 3); hash ^= (hash >> 11); hash += (hash << 15); + + return hash; +} + +/* + * hash_reddragon() Compute index hash by Red Dragon + * @csStr = Input data buffer + * @nStrLen = Length of data buffer + * return: Hash value +*/ +inline u_int +hash_reddragon(const char *csStr, int nStrLen) +{ + register u_int g, hash; + register int i; + + assert(csStr); + + for (hash = 0, i = 0; i < nStrLen; i++) { + hash = (hash << 4) + csStr[i]; + if ((g = hash & 0xF0000000)) { + hash ^= g >> 24; + hash ^= g; + } + } return hash; }