windows-nt/Source/XPSP1/NT/sdktools/m4/hash.c
2020-09-26 16:20:57 +08:00

44 lines
997 B
C

/*****************************************************************************
*
* hash.c
*
* Hashing tokens.
*
*****************************************************************************/
#include "m4.h"
/*****************************************************************************
*
* hashPtok
*
* Hash a token.
*
* For now, use some hash function.
*
*****************************************************************************/
HASH STDCALL
hashPtok(PCTOK ptok)
{
HASH hash = 0;
PTCH ptch;
for (ptch = ptchPtok(ptok); ptch < ptchMaxPtok(ptok); ptch++) {
hash += (hash << 1) + (hash >> 1) + *ptch;
}
return hash % g_hashMod;
}
/*****************************************************************************
*
* InitHash
*
*****************************************************************************/
void STDCALL
InitHash(void)
{
mphashpmac = pvAllocCb(g_hashMod * sizeof(PMAC));
bzero(mphashpmac, g_hashMod * sizeof(PMAC));
}