mirror of
https://github.com/Laupetin/OpenAssetTools.git
synced 2025-06-13 00:08:26 -05:00
chore: update all usages of memory manager allocation
This commit is contained in:
@ -249,7 +249,7 @@ bool AssetLoaderFontIcon::LoadFromRaw(
|
||||
|
||||
if (fontIcon->numEntries > 0)
|
||||
{
|
||||
fontIcon->fontIconEntry = static_cast<FontIconEntry*>(memory->Alloc(sizeof(FontIconEntry) * fontIcon->numEntries));
|
||||
fontIcon->fontIconEntry = memory->Alloc<FontIconEntry>(fontIcon->numEntries);
|
||||
for (auto i = 0u; i < entries.size(); i++)
|
||||
fontIcon->fontIconEntry[i] = entries[i];
|
||||
}
|
||||
@ -258,7 +258,7 @@ bool AssetLoaderFontIcon::LoadFromRaw(
|
||||
|
||||
if (fontIcon->numAliasEntries > 0)
|
||||
{
|
||||
fontIcon->fontIconAlias = static_cast<FontIconAlias*>(memory->Alloc(sizeof(FontIconAlias) * fontIcon->numAliasEntries));
|
||||
fontIcon->fontIconAlias = memory->Alloc<FontIconAlias>(fontIcon->numAliasEntries);
|
||||
for (auto i = 0u; i < aliases.size(); i++)
|
||||
fontIcon->fontIconAlias[i] = aliases[i];
|
||||
}
|
||||
|
@ -46,8 +46,7 @@ bool AssetLoaderMaterial::LoadFromRaw(
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
auto* material = static_cast<Material*>(memory->Alloc(sizeof(Material)));
|
||||
memset(material, 0, sizeof(Material));
|
||||
auto* material = memory->Alloc<Material>();
|
||||
material->info.name = memory->Dup(assetName.c_str());
|
||||
|
||||
std::vector<XAssetInfoGeneric*> dependencies;
|
||||
|
@ -30,7 +30,7 @@ bool AssetLoaderQdb::LoadFromRaw(const std::string& assetName, ISearchPath* sear
|
||||
qdb->name = memory->Dup(assetName.c_str());
|
||||
qdb->len = static_cast<int>(file.m_length);
|
||||
|
||||
auto* fileBuffer = static_cast<char*>(memory->Alloc(static_cast<size_t>(file.m_length + 1)));
|
||||
auto* fileBuffer = memory->Alloc<char>(static_cast<size_t>(file.m_length + 1));
|
||||
file.m_stream->read(fileBuffer, file.m_length);
|
||||
if (file.m_stream->gcount() != file.m_length)
|
||||
return false;
|
||||
|
@ -35,7 +35,7 @@ bool AssetLoaderRawFile::LoadAnimtree(
|
||||
return false;
|
||||
|
||||
const auto compressionBufferSize = static_cast<size_t>(file.m_length + sizeof(uint32_t) + COMPRESSED_BUFFER_SIZE_PADDING);
|
||||
auto* compressedBuffer = static_cast<char*>(memory->Alloc(compressionBufferSize));
|
||||
auto* compressedBuffer = memory->Alloc<char>(compressionBufferSize);
|
||||
|
||||
z_stream_s zs{};
|
||||
|
||||
@ -86,7 +86,7 @@ bool AssetLoaderRawFile::LoadDefault(
|
||||
rawFile->name = memory->Dup(assetName.c_str());
|
||||
rawFile->len = static_cast<int>(file.m_length);
|
||||
|
||||
auto* fileBuffer = static_cast<char*>(memory->Alloc(static_cast<size_t>(file.m_length + 1)));
|
||||
auto* fileBuffer = memory->Alloc<char>(static_cast<size_t>(file.m_length + 1));
|
||||
file.m_stream->read(fileBuffer, file.m_length);
|
||||
if (file.m_stream->gcount() != file.m_length)
|
||||
return false;
|
||||
|
@ -31,7 +31,7 @@ bool AssetLoaderScriptParseTree::LoadFromRaw(
|
||||
scriptParseTree->name = memory->Dup(assetName.c_str());
|
||||
scriptParseTree->len = static_cast<int>(file.m_length);
|
||||
|
||||
auto* fileBuffer = static_cast<char*>(memory->Alloc(static_cast<size_t>(file.m_length + 1)));
|
||||
auto* fileBuffer = memory->Alloc<char>(static_cast<size_t>(file.m_length + 1));
|
||||
file.m_stream->read(fileBuffer, file.m_length);
|
||||
if (file.m_stream->gcount() != file.m_length)
|
||||
return false;
|
||||
|
@ -30,7 +30,7 @@ bool AssetLoaderSlug::LoadFromRaw(const std::string& assetName, ISearchPath* sea
|
||||
slug->name = memory->Dup(assetName.c_str());
|
||||
slug->len = static_cast<int>(file.m_length);
|
||||
|
||||
auto* fileBuffer = static_cast<char*>(memory->Alloc(static_cast<size_t>(file.m_length + 1)));
|
||||
auto* fileBuffer = memory->Alloc<char>(static_cast<size_t>(file.m_length + 1));
|
||||
file.m_stream->read(fileBuffer, file.m_length);
|
||||
if (file.m_stream->gcount() != file.m_length)
|
||||
return false;
|
||||
|
@ -199,7 +199,7 @@ bool LoadSoundAlias(MemoryManager* memory, SndAlias* alias, const ParsedCsvRow&
|
||||
bool LoadSoundAliasIndexList(MemoryManager* memory, SndBank* sndBank)
|
||||
{
|
||||
// contains a list of all the alias ids in the sound bank
|
||||
sndBank->aliasIndex = static_cast<SndIndexEntry*>(memory->Alloc(sizeof(SndIndexEntry) * sndBank->aliasCount));
|
||||
sndBank->aliasIndex = memory->Alloc<SndIndexEntry>(sndBank->aliasCount);
|
||||
memset(sndBank->aliasIndex, 0xFF, sizeof(SndIndexEntry) * sndBank->aliasCount);
|
||||
|
||||
const auto setAliasIndexList = std::make_unique<bool[]>(sndBank->aliasCount);
|
||||
@ -271,8 +271,7 @@ bool LoadSoundAliasList(
|
||||
{
|
||||
// should be the total number of assets
|
||||
sndBank->aliasCount = aliasCsv.Size();
|
||||
sndBank->alias = static_cast<SndAliasList*>(memory->Alloc(sizeof(SndAliasList) * sndBank->aliasCount));
|
||||
memset(sndBank->alias, 0, sizeof(SndAliasList) * sndBank->aliasCount);
|
||||
sndBank->alias = memory->Alloc<SndAliasList>(sndBank->aliasCount);
|
||||
|
||||
auto row = 0u;
|
||||
auto listIndex = 0u;
|
||||
@ -286,7 +285,7 @@ bool LoadSoundAliasList(
|
||||
|
||||
// allocate the sub list
|
||||
sndBank->alias[listIndex].count = subListCount;
|
||||
sndBank->alias[listIndex].head = static_cast<SndAlias*>(memory->Alloc(sizeof(SndAlias) * subListCount));
|
||||
sndBank->alias[listIndex].head = memory->Alloc<SndAlias>(subListCount);
|
||||
sndBank->alias[listIndex].sequence = 0;
|
||||
|
||||
// populate the sublist with the next X number of aliases in the file. Note: this will only work correctly if the aliases that are a part of a sub
|
||||
@ -319,7 +318,7 @@ bool LoadSoundAliasList(
|
||||
auto* oldAliases = sndBank->alias;
|
||||
|
||||
sndBank->aliasCount = listIndex;
|
||||
sndBank->alias = static_cast<SndAliasList*>(memory->Alloc(sizeof(SndAliasList) * sndBank->aliasCount));
|
||||
sndBank->alias = memory->Alloc<SndAliasList>(sndBank->aliasCount);
|
||||
memcpy(sndBank->alias, oldAliases, sizeof(SndAliasList) * sndBank->aliasCount);
|
||||
|
||||
memory->Free(oldAliases);
|
||||
@ -340,8 +339,7 @@ bool LoadSoundRadverbs(MemoryManager* memory, SndBank* sndBank, const SearchPath
|
||||
if (radverbCsv.Size() > 0)
|
||||
{
|
||||
sndBank->radverbCount = radverbCsv.Size();
|
||||
sndBank->radverbs = static_cast<SndRadverb*>(memory->Alloc(sizeof(SndRadverb) * sndBank->radverbCount));
|
||||
memset(sndBank->radverbs, 0, sizeof(SndRadverb) * sndBank->radverbCount);
|
||||
sndBank->radverbs = memory->Alloc<SndRadverb>(sndBank->radverbCount);
|
||||
|
||||
for (auto i = 0u; i < sndBank->radverbCount; i++)
|
||||
{
|
||||
@ -383,8 +381,7 @@ bool LoadSoundDuckList(ISearchPath* searchPath, MemoryManager* memory, SndBank*
|
||||
if (duckListCsv.Size() > 0)
|
||||
{
|
||||
sndBank->duckCount = duckListCsv.Size();
|
||||
sndBank->ducks = static_cast<SndDuck*>(memory->Alloc(sizeof(SndDuck) * sndBank->duckCount));
|
||||
memset(sndBank->ducks, 0, sizeof(SndDuck) * sndBank->duckCount);
|
||||
sndBank->ducks = memory->Alloc<SndDuck>(sndBank->duckCount);
|
||||
|
||||
for (auto i = 0u; i < sndBank->duckCount; i++)
|
||||
{
|
||||
@ -422,8 +419,8 @@ bool LoadSoundDuckList(ISearchPath* searchPath, MemoryManager* memory, SndBank*
|
||||
if (duckJson.contains("fadeOutCurve"))
|
||||
duck->fadeOutCurve = Common::SND_HashName(duckJson["fadeOutCurve"].get<std::string>().data());
|
||||
|
||||
duck->attenuation = static_cast<SndFloatAlign16*>(memory->Alloc(sizeof(SndFloatAlign16) * 32));
|
||||
duck->filter = static_cast<SndFloatAlign16*>(memory->Alloc(sizeof(SndFloatAlign16) * 32));
|
||||
duck->attenuation = memory->Alloc<SndFloatAlign16>(32u);
|
||||
duck->filter = memory->Alloc<SndFloatAlign16>(32u);
|
||||
|
||||
for (auto& valueJson : duckJson["values"])
|
||||
{
|
||||
@ -499,8 +496,7 @@ bool AssetLoaderSoundBank::LoadFromRaw(
|
||||
sndBank->loadedAssets.zone = memory->Dup(sndBankLocalization.at(0).c_str());
|
||||
sndBank->loadedAssets.language = memory->Dup(sndBankLocalization.at(1).c_str());
|
||||
sndBank->loadedAssets.entryCount = loadedEntryCount;
|
||||
sndBank->loadedAssets.entries = static_cast<SndAssetBankEntry*>(memory->Alloc(sizeof(SndAssetBankEntry) * loadedEntryCount));
|
||||
memset(sndBank->loadedAssets.entries, 0, sizeof(SndAssetBankEntry) * loadedEntryCount);
|
||||
sndBank->loadedAssets.entries = memory->Alloc<SndAssetBankEntry>(loadedEntryCount);
|
||||
|
||||
sndBank->runtimeAssetLoad = true;
|
||||
|
||||
@ -550,8 +546,7 @@ bool AssetLoaderSoundBank::LoadFromRaw(
|
||||
if (result)
|
||||
{
|
||||
sndBank->loadedAssets.dataSize = dataSize;
|
||||
sndBank->loadedAssets.data = static_cast<SndChar2048*>(memory->Alloc(dataSize));
|
||||
memset(sndBank->loadedAssets.data, 0, dataSize);
|
||||
sndBank->loadedAssets.data = memory->Alloc<SndChar2048>(dataSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -70,7 +70,7 @@ namespace T6
|
||||
}
|
||||
|
||||
assert(std::extent_v<decltype(bounceSoundSuffixes)> == SURF_TYPE_NUM);
|
||||
*bounceSound = static_cast<const char**>(m_memory->Alloc(sizeof(const char*) * SURF_TYPE_NUM));
|
||||
*bounceSound = m_memory->Alloc<const char*>(SURF_TYPE_NUM);
|
||||
for (auto i = 0u; i < SURF_TYPE_NUM; i++)
|
||||
{
|
||||
const auto currentBounceSound = value + bounceSoundSuffixes[i];
|
||||
|
@ -32,8 +32,7 @@ bool AssetLoaderWeaponCamo::LoadFromRaw(
|
||||
if (!file.IsOpen())
|
||||
return false;
|
||||
|
||||
auto* weaponCamo = static_cast<WeaponCamo*>(memory->Alloc(sizeof(WeaponCamo)));
|
||||
memset(weaponCamo, 0, sizeof(WeaponCamo));
|
||||
auto* weaponCamo = memory->Alloc<WeaponCamo>();
|
||||
weaponCamo->name = memory->Dup(assetName.c_str());
|
||||
|
||||
std::vector<XAssetInfoGeneric*> dependencies;
|
||||
|
Reference in New Issue
Block a user