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.

87 lines
2.4 KiB

  1. #pragma once
  2. #include "positionindependentblob.h"
  3. #include "pshpack8.h"
  4. class CHashTableInit;
  5. class CPositionIndependentHashTable;
  6. typedef int (__stdcall PFN_COMPARE_FUNCTION)(const BYTE * Key1, const BYTE * Key2);
  7. typedef BOOL (__stdcall PFN_EQUAL_FUNCTION)(const BYTE * Key1, const BYTE * Key2);
  8. typedef ULONG (__stdcall PFN_HASH_FUNCTION)(const BYTE * Key);
  9. class CPositionIndependentHashTable : public CPositionIndependentBlob
  10. //
  11. // multiple hashes over the same keys/values
  12. //
  13. {
  14. private:
  15. typedef CPositionIndependentBlob Base;
  16. public:
  17. CPositionIndependentHashTable();
  18. ~CPositionIndependentHashTable();
  19. ULONG PointerToOffset(const BYTE *);
  20. ULONG m_NumberOfHashTables;
  21. ULONG m_OffsetToHashTables; // bytes
  22. void Alloc(ULONG NumberOfBytes, ULONG * Offset);
  23. class CHashTableElement
  24. {
  25. public:
  26. ULONG m_PseudoKey; // aka Hash
  27. ULONG m_KeySize : 31;
  28. ULONG m_ValueSize : 31;
  29. ULONG m_ValueAllocatedSize : 31;
  30. ULONG m_InUse : 1;
  31. ULONG m_Spare : 3;
  32. union
  33. {
  34. ULONG m_OffsetToKey;
  35. ULONGLONG m_SmallKey;
  36. };
  37. union
  38. {
  39. ULONG m_OffsetToValue;
  40. ULONGLONG m_SmallValue;
  41. };
  42. };
  43. public:
  44. class CHashTableBucket
  45. {
  46. public:
  47. ULONG m_AllocatedElementsInBucket;
  48. ULONG m_OffsetToElements;
  49. };
  50. class CHashTable : public CPositionIndependentOperatorNew
  51. {
  52. public:
  53. CHashTable(CPositionIndependentBlob * Container);
  54. CFunction<PFN_COMPARE_FUNCTION> m_Compare;
  55. CFunction<PFN_EQUAL_FUNCTION> m_Equal;
  56. CFunction<PFN_HASH_FUNCTION> m_Hash;
  57. ULONG m_NumberOfBuckets;
  58. ULONG m_NumberOfElementsInTable;
  59. ULONG m_OffsetToBuckets;
  60. };
  61. void ThrAddHashTable(const CHashTableInit *);
  62. void ThrAddHashTables(ULONG NumberOfHashTables, const CHashTableInit *);
  63. };
  64. #include "poppack.h"
  65. class CHashTableInit
  66. {
  67. public:
  68. ULONG m_NumberOfBuckets;
  69. CFunction<PFN_COMPARE_FUNCTION> m_Compare;
  70. CFunction<PFN_HASH_FUNCTION> m_Hash;
  71. CFunction<PFN_EQUAL_FUNCTION> m_Equal;
  72. };