mirror of
https://github.com/LostArtefacts/TRX.git
synced 2025-04-28 20:58:07 +03:00
game-strings: fix memory leak
This commit is contained in:
parent
3e4017d338
commit
9c0c0160df
2 changed files with 5 additions and 4 deletions
|
@ -137,7 +137,7 @@ void GameStringTable_Apply(const GF_LEVEL *const level)
|
||||||
Object_ResetNames();
|
Object_ResetNames();
|
||||||
ASSERT(m_GST_Layers != nullptr);
|
ASSERT(m_GST_Layers != nullptr);
|
||||||
for (int32_t i = 0; i < m_GST_Layers->count; i++) {
|
for (int32_t i = 0; i < m_GST_Layers->count; i++) {
|
||||||
const GS_FILE *const gs_file = Vector_Get(m_GST_Layers, i);
|
const GS_FILE *const gs_file = *(GS_FILE **)Vector_Get(m_GST_Layers, i);
|
||||||
M_ApplyLayer(level, gs_file);
|
M_ApplyLayer(level, gs_file);
|
||||||
}
|
}
|
||||||
M_DoObjectAliases();
|
M_DoObjectAliases();
|
||||||
|
@ -145,14 +145,14 @@ void GameStringTable_Apply(const GF_LEVEL *const level)
|
||||||
|
|
||||||
void GameStringTable_Init(void)
|
void GameStringTable_Init(void)
|
||||||
{
|
{
|
||||||
m_GST_Layers = Vector_Create(sizeof(GS_FILE));
|
m_GST_Layers = Vector_Create(sizeof(GS_FILE *));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GameStringTable_Shutdown(void)
|
void GameStringTable_Shutdown(void)
|
||||||
{
|
{
|
||||||
if (m_GST_Layers != nullptr) {
|
if (m_GST_Layers != nullptr) {
|
||||||
for (int32_t i = 0; i < m_GST_Layers->count; i++) {
|
for (int32_t i = 0; i < m_GST_Layers->count; i++) {
|
||||||
GS_FILE *const gs_file = Vector_Get(m_GST_Layers, i);
|
GS_FILE *const gs_file = *(GS_FILE **)Vector_Get(m_GST_Layers, i);
|
||||||
GS_File_Free(gs_file);
|
GS_File_Free(gs_file);
|
||||||
}
|
}
|
||||||
Vector_Free(m_GST_Layers);
|
Vector_Free(m_GST_Layers);
|
||||||
|
@ -168,6 +168,6 @@ void GameStringTable_Load(const char *const path, const bool load_levels)
|
||||||
}
|
}
|
||||||
GS_FILE *gs_file = GS_File_CreateFromString(data, load_levels);
|
GS_FILE *gs_file = GS_File_CreateFromString(data, load_levels);
|
||||||
ASSERT(m_GST_Layers != nullptr);
|
ASSERT(m_GST_Layers != nullptr);
|
||||||
Vector_Add(m_GST_Layers, gs_file);
|
Vector_Add(m_GST_Layers, &gs_file);
|
||||||
Memory_FreePointer(&data);
|
Memory_FreePointer(&data);
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,4 +52,5 @@ void GS_File_Free(GS_FILE *const gs_file)
|
||||||
for (int32_t i = 0; i < GFLT_NUMBER_OF; i++) {
|
for (int32_t i = 0; i < GFLT_NUMBER_OF; i++) {
|
||||||
M_FreeLevelsTable(&gs_file->level_tables[i]);
|
M_FreeLevelsTable(&gs_file->level_tables[i]);
|
||||||
}
|
}
|
||||||
|
Memory_Free(gs_file);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue