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.

67 lines
1.9 KiB

  1. #include "stdinc.h"
  2. #include "lhport.h"
  3. #include "windows.h"
  4. #include "numberof.h"
  5. #include "positionindependenthashtable.h"
  6. void
  7. CPositionIndependentHashTable::Alloc(
  8. ULONG NumberOfBytes,
  9. ULONG * Offset
  10. )
  11. {
  12. Base::Alloc(NumberOfBytes, Offset);
  13. }
  14. CPositionIndependentHashTable::CPositionIndependentHashTable()
  15. :
  16. m_NumberOfHashTables(0),
  17. m_OffsetToHashTables(0)
  18. {
  19. }
  20. void CPositionIndependentHashTable::ThrAddHashTable(
  21. const CHashTableInit * Init
  22. )
  23. {
  24. ThrAddHashTables(1, Init);
  25. }
  26. void CPositionIndependentHashTable::ThrAddHashTables(
  27. ULONG NumberOfHashTables,
  28. const CHashTableInit * Inits
  29. )
  30. {
  31. CHashTable * PointerToHashTables = 0;
  32. m_NumberOfHashTables = NumberOfHashTables;
  33. ULONG SizeOfHashes = NumberOfHashTables * sizeof(*PointerToHashTables);
  34. ULONG OffsetToHashTables = 0;
  35. Alloc(SizeOfHashes, &OffsetToHashTables);
  36. m_OffsetToHashTables = OffsetToHashTables;
  37. OffsetToPointer(OffsetToHashTables, &PointerToHashTables);
  38. for ( ULONG HashTableIndex = 0 ; HashTableIndex != NumberOfHashTables ; ++HashTableIndex)
  39. {
  40. CHashTableBucket * PointerToBuckets = 0;
  41. CHashTable * PointerToHashTable = &PointerToHashTables[HashTableIndex];
  42. PointerToHashTable->m_NumberOfElementsInTable = 0;
  43. PointerToHashTable->m_Compare = Inits[HashTableIndex].m_Compare;
  44. PointerToHashTable->m_Hash = Inits[HashTableIndex].m_Hash;
  45. ULONG NumberOfBuckets = Inits[HashTableIndex].m_NumberOfBuckets;
  46. PointerToHashTable->m_NumberOfBuckets = NumberOfBuckets;
  47. ULONG OffsetToBuckets;
  48. Alloc(NumberOfBuckets * sizeof(*PointerToBuckets), &OffsetToBuckets);
  49. PointerToHashTable->m_OffsetToBuckets = OffsetToBuckets;
  50. OffsetToPointer(OffsetToBuckets, &PointerToBuckets);
  51. for (ULONG BucketIndex = 0 ; BucketIndex != NumberOfBuckets ; ++BucketIndex )
  52. {
  53. PointerToBuckets[BucketIndex].m_AllocatedElementsInBucket = 0;
  54. }
  55. }
  56. }