Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
1.0 KiB

  1. /*****************************************************************************
  2. *
  3. * hash.c
  4. *
  5. * Hashing tokens.
  6. *
  7. *****************************************************************************/
  8. #include "m4.h"
  9. /*****************************************************************************
  10. *
  11. * hashPtok
  12. *
  13. * Hash a token.
  14. *
  15. * For now, use some hash function.
  16. *
  17. *****************************************************************************/
  18. HASH STDCALL
  19. hashPtok(PCTOK ptok)
  20. {
  21. HASH hash = 0;
  22. PTCH ptch;
  23. for (ptch = ptchPtok(ptok); ptch < ptchMaxPtok(ptok); ptch++) {
  24. hash += (hash << 1) + (hash >> 1) + *ptch;
  25. }
  26. return hash % g_hashMod;
  27. }
  28. /*****************************************************************************
  29. *
  30. * InitHash
  31. *
  32. *****************************************************************************/
  33. void STDCALL
  34. InitHash(void)
  35. {
  36. mphashpmac = pvAllocCb(g_hashMod * sizeof(PMAC));
  37. bzero(mphashpmac, g_hashMod * sizeof(PMAC));
  38. }