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

Function FindFreeHashEntry

3rdParty/StormLib/src/SBaseSubTypes.cpp:441–471  ·  view source on GitHub ↗

Attempts to search a free hash entry in the hash table being converted. The created hash table must always be of nonzero size, should have no duplicated items and no deleted entries

Source from the content-addressed store, hash-verified

439// The created hash table must always be of nonzero size,
440// should have no duplicated items and no deleted entries
441TMPQHash * FindFreeHashEntry(TMPQHash * pHashTable, DWORD dwHashTableSize, DWORD dwStartIndex)
442{
443 TMPQHash * pHash;
444 DWORD dwIndex;
445
446 // Set the initial index
447 dwStartIndex = dwIndex = (dwStartIndex & (dwHashTableSize - 1));
448 assert(dwHashTableSize != 0);
449
450 // Search the hash table and return the found entries in the following priority:
451 for(;;)
452 {
453 // We are not expecting to find matching entry in the hash table being built
454 // We are not expecting to find deleted entry either
455 pHash = pHashTable + dwIndex;
456
457 // If we found a free entry, we need to stop searching
458 if(pHash->dwBlockIndex == HASH_ENTRY_FREE)
459 return pHash;
460
461 // Move to the next hash entry.
462 // If we reached the starting entry, it's failure.
463 dwIndex = (dwIndex + 1) & (dwHashTableSize - 1);
464 if(dwIndex == dwStartIndex)
465 break;
466 }
467
468 // We haven't found anything
469 assert(false);
470 return NULL;
471}
472
473void DecryptMpkTable(void * pvMpkTable, size_t cbSize)
474{

Callers 1

LoadMpkHashTableFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected