MCPcopy Create free account
hub / github.com/diasurgical/devilution / CreateHashTable

Function CreateHashTable

3rdParty/StormLib/src/SBaseFileTable.cpp:2141–2164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2139// Support for file tables - hash table, block table, hi-block table
2140
2141int CreateHashTable(TMPQArchive * ha, DWORD dwHashTableSize)
2142{
2143 TMPQHash * pHashTable;
2144
2145 // Sanity checks
2146 assert((dwHashTableSize & (dwHashTableSize - 1)) == 0);
2147 assert(ha->pHashTable == NULL);
2148
2149 // If the required hash table size is zero, don't create anything
2150 if(dwHashTableSize == 0)
2151 dwHashTableSize = HASH_TABLE_SIZE_DEFAULT;
2152
2153 // Create the hash table
2154 pHashTable = STORM_ALLOC(TMPQHash, dwHashTableSize);
2155 if(pHashTable == NULL)
2156 return ERROR_NOT_ENOUGH_MEMORY;
2157
2158 // Fill it
2159 memset(pHashTable, 0xFF, dwHashTableSize * sizeof(TMPQHash));
2160 ha->pHeader->dwHashTableSize = dwHashTableSize;
2161 ha->dwMaxFileCount = dwHashTableSize;
2162 ha->pHashTable = pHashTable;
2163 return ERROR_SUCCESS;
2164}
2165
2166static TMPQHash * LoadHashTable(TMPQArchive * ha)
2167{

Callers 1

LoadAnyHashTableFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected