- use a single TArray to allocate the memory for the lump manager's hash lists.

This commit is contained in:
Christoph Oelckers 2018-11-02 09:51:44 +01:00
parent 8597c9e326
commit c07aeb7498
2 changed files with 9 additions and 43 deletions

View file

@ -101,10 +101,6 @@ void uppercopy (char *to, const char *from)
} }
FWadCollection::FWadCollection () FWadCollection::FWadCollection ()
: FirstLumpIndex(NULL), NextLumpIndex(NULL),
FirstLumpIndex_FullName(NULL), NextLumpIndex_FullName(NULL),
FirstLumpIndex_NoExt(NULL), NextLumpIndex_NoExt(NULL),
NumLumps(0)
{ {
} }
@ -115,37 +111,6 @@ FWadCollection::~FWadCollection ()
void FWadCollection::DeleteAll () void FWadCollection::DeleteAll ()
{ {
if (FirstLumpIndex != NULL)
{
delete[] FirstLumpIndex;
FirstLumpIndex = NULL;
}
if (NextLumpIndex != NULL)
{
delete[] NextLumpIndex;
NextLumpIndex = NULL;
}
if (FirstLumpIndex_FullName != NULL)
{
delete[] FirstLumpIndex_FullName;
FirstLumpIndex_FullName = NULL;
}
if (NextLumpIndex_FullName != NULL)
{
delete[] NextLumpIndex_FullName;
NextLumpIndex_FullName = NULL;
}
if (FirstLumpIndex_NoExt != NULL)
{
delete[] FirstLumpIndex_NoExt;
FirstLumpIndex_NoExt = NULL;
}
if (NextLumpIndex_NoExt != NULL)
{
delete[] NextLumpIndex_NoExt;
NextLumpIndex_NoExt = NULL;
}
LumpInfo.Clear(); LumpInfo.Clear();
NumLumps = 0; NumLumps = 0;
@ -193,12 +158,13 @@ void FWadCollection::InitMultipleFiles (TArray<FString> &filenames)
FixMacHexen(); FixMacHexen();
// [RH] Set up hash table // [RH] Set up hash table
FirstLumpIndex = new uint32_t[NumLumps]; Hashes.Resize(6 * NumLumps);
NextLumpIndex = new uint32_t[NumLumps]; FirstLumpIndex = &Hashes[0];
FirstLumpIndex_FullName = new uint32_t[NumLumps]; NextLumpIndex = &Hashes[NumLumps];
NextLumpIndex_FullName = new uint32_t[NumLumps]; FirstLumpIndex_FullName = &Hashes[NumLumps*2];
FirstLumpIndex_NoExt = new uint32_t[NumLumps]; NextLumpIndex_FullName = &Hashes[NumLumps*3];
NextLumpIndex_NoExt = new uint32_t[NumLumps]; FirstLumpIndex_NoExt = &Hashes[NumLumps*4];
NextLumpIndex_NoExt = &Hashes[NumLumps*5];
InitHashChains (); InitHashChains ();
LumpInfo.ShrinkToFit(); LumpInfo.ShrinkToFit();
Files.ShrinkToFit(); Files.ShrinkToFit();

View file

@ -188,6 +188,7 @@ protected:
TArray<FResourceFile *> Files; TArray<FResourceFile *> Files;
TArray<LumpRecord> LumpInfo; TArray<LumpRecord> LumpInfo;
TArray<uint32_t> Hashes; // one allocation for all hash lists.
uint32_t *FirstLumpIndex; // [RH] Hashing stuff moved out of lumpinfo structure uint32_t *FirstLumpIndex; // [RH] Hashing stuff moved out of lumpinfo structure
uint32_t *NextLumpIndex; uint32_t *NextLumpIndex;
@ -197,12 +198,11 @@ protected:
uint32_t *FirstLumpIndex_NoExt; // The same information for fully qualified paths from .zips uint32_t *FirstLumpIndex_NoExt; // The same information for fully qualified paths from .zips
uint32_t *NextLumpIndex_NoExt; uint32_t *NextLumpIndex_NoExt;
uint32_t NumLumps; // Not necessarily the same as LumpInfo.Size() uint32_t NumLumps = 0; // Not necessarily the same as LumpInfo.Size()
uint32_t NumWads; uint32_t NumWads;
int IwadIndex; int IwadIndex;
void SkinHack (int baselump);
void InitHashChains (); // [RH] Set up the lumpinfo hashing void InitHashChains (); // [RH] Set up the lumpinfo hashing
private: private: