Windows NT 4.0 source code leak
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.

74 lines
2.5 KiB

4 years ago
  1. /***********************************************************************
  2. * Microsoft (R) 32-Bit Incremental Linker
  3. *
  4. * Copyright (C) Microsoft Corp 1992-95. All rights reserved.
  5. *
  6. * File: hash.h
  7. *
  8. * File Comments:
  9. *
  10. * Hash table data structures.
  11. *
  12. ***********************************************************************/
  13. #ifndef __HASH_H__
  14. #define __HASH_H__
  15. // dynamic hash table element
  16. typedef struct ELEMENT
  17. {
  18. void *pv; // contents, HT can retrieve key from this
  19. struct ELEMENT *pelementNext; // bucket pointer
  20. } ELEMENT, *PELEMENT;
  21. // a chunk of memory for dynamic arrays which underly dynamic hash tables
  22. typedef struct CHUNK
  23. {
  24. PELEMENT *rgpelement;
  25. } CHUNK, *PCHUNK, **PPCHUNK;
  26. // hash table enumeration state
  27. typedef struct STATE
  28. {
  29. DWORD iLast; // next element to be enumerated
  30. DWORD cFound; // # elements found in enumeration so far
  31. PELEMENT pelementLast; // next elemnet to be enumerated
  32. struct STATE *pstateNext; // next element in stack
  33. } STATE, *PSTATE;
  34. // dynamic hash table flags
  35. #define HT_Full 0x1U // hash table full
  36. #define HT_InsertsNotAllowed 0x2U // inserts not allowed in hash table
  37. // dynamic hash table data structure
  38. typedef struct HT
  39. {
  40. DWORD iNextToSplit; // next bucket that will be split
  41. DWORD iNextToSplitMax; // maximum number of buckets this round
  42. DWORD cbuckets; // number of buckets in the table
  43. DWORD celements; // number of elements in the table
  44. DWORD cExpands; // number of times table was expanded
  45. DWORD cchunkInDir; // number of chunks in a directory
  46. DWORD celementInChunk; // number elmenents in a chunk
  47. WORD flags; // flag set if table is full
  48. const char * (*SzFromPv)(PVOID, PVOID); // retrieve a key from an elements data
  49. PSTATE pstateStack; // enumeration state stack
  50. PCHUNK *rgpchunk; // dynamic array containing hash table
  51. } HT, *PHT, **PPHT;
  52. PELEMENT PelementLookup_HT(const char *, PHT, BOOL, PVOID, PBOOL);
  53. PELEMENT PelementEnumerateNext_HT(PHT);
  54. VOID Init_HT(PPHT, DWORD, DWORD, const char * (*)(PVOID, PVOID), WORD);
  55. VOID Free_HT(PPHT);
  56. VOID InitEnumeration_HT(PHT);
  57. VOID TerminateEnumerate_HT(PHT);
  58. VOID SetStatus_HT(PHT, WORD);
  59. WORD GetStatus_HT(PHT);
  60. DWORD Celement_HT(PHT);
  61. #if DBG
  62. VOID Statistics_HT(PHT);
  63. VOID Dump_HT(PHT, PVOID);
  64. #endif // DBG
  65. #endif // __HASH_H__