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

#include "stdinc.h"
#include "lhport.h"
#include "windows.h"
#include "numberof.h"
#include "positionindependenthashtable.h"
void
CPositionIndependentHashTable::Alloc(
ULONG NumberOfBytes,
ULONG * Offset
)
{
Base::Alloc(NumberOfBytes, Offset);
}
CPositionIndependentHashTable::CPositionIndependentHashTable()
:
m_NumberOfHashTables(0),
m_OffsetToHashTables(0)
{
}
void CPositionIndependentHashTable::ThrAddHashTable(
const CHashTableInit * Init
)
{
ThrAddHashTables(1, Init);
}
void CPositionIndependentHashTable::ThrAddHashTables(
ULONG NumberOfHashTables,
const CHashTableInit * Inits
)
{
CHashTable * PointerToHashTables = 0;
m_NumberOfHashTables = NumberOfHashTables;
ULONG SizeOfHashes = NumberOfHashTables * sizeof(*PointerToHashTables);
ULONG OffsetToHashTables = 0;
Alloc(SizeOfHashes, &OffsetToHashTables);
m_OffsetToHashTables = OffsetToHashTables;
OffsetToPointer(OffsetToHashTables, &PointerToHashTables);
for ( ULONG HashTableIndex = 0 ; HashTableIndex != NumberOfHashTables ; ++HashTableIndex)
{
CHashTableBucket * PointerToBuckets = 0;
CHashTable * PointerToHashTable = &PointerToHashTables[HashTableIndex];
PointerToHashTable->m_NumberOfElementsInTable = 0;
PointerToHashTable->m_Compare = Inits[HashTableIndex].m_Compare;
PointerToHashTable->m_Hash = Inits[HashTableIndex].m_Hash;
ULONG NumberOfBuckets = Inits[HashTableIndex].m_NumberOfBuckets;
PointerToHashTable->m_NumberOfBuckets = NumberOfBuckets;
ULONG OffsetToBuckets;
Alloc(NumberOfBuckets * sizeof(*PointerToBuckets), &OffsetToBuckets);
PointerToHashTable->m_OffsetToBuckets = OffsetToBuckets;
OffsetToPointer(OffsetToBuckets, &PointerToBuckets);
for (ULONG BucketIndex = 0 ; BucketIndex != NumberOfBuckets ; ++BucketIndex )
{
PointerToBuckets[BucketIndex].m_AllocatedElementsInBucket = 0;
}
}
}