Skip to content

Commit

Permalink
fixed memory leak with new game picker.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Jan 6, 2024
1 parent 406cb04 commit 905cebf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
3 changes: 1 addition & 2 deletions source/common/filesystem/source/fs_stringpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class StringPool
friend class FileSystem;
friend class FResourceFile;
private:
StringPool(bool _shared, size_t blocksize = 10*1024) : TopBlock(nullptr), FreeBlocks(nullptr), BlockSize(blocksize), shared(_shared) {}
StringPool(bool _shared, size_t blocksize = 10*1024) : TopBlock(nullptr), BlockSize(blocksize), shared(_shared) {}
public:
~StringPool();
const char* Strdup(const char*);
Expand All @@ -20,7 +20,6 @@ class StringPool
Block *AddBlock(size_t size);

Block *TopBlock;
Block *FreeBlocks;
size_t BlockSize;
public:
bool shared;
Expand Down
5 changes: 5 additions & 0 deletions source/common/widgets/widgetresourcedata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ void InitWidgetResources(const char* filename)
I_FatalError("Unable to open %s", filename);
}

void CloseWidgetResources()
{
if (WidgetResources) delete WidgetResources;
}

static std::vector<uint8_t> LoadFile(const std::string& name)
{
auto lump = WidgetResources->FindEntry(name.c_str());
Expand Down
2 changes: 2 additions & 0 deletions source/core/gamecontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

void LoadHexFont(const char* filename);
void InitWidgetResources(const char* basewad);
void CloseWidgetResources();

CVAR(Bool, autoloadlights, true, CVAR_ARCHIVE|CVAR_GLOBALCONFIG)
CVAR(Bool, autoloadbrightmaps, true, CVAR_ARCHIVE | CVAR_GLOBALCONFIG)
Expand Down Expand Up @@ -1050,6 +1051,7 @@ int RunGame()
GetGames();
auto usedgroups = SetupGame();

CloseWidgetResources();
V_InitScreenSize();
V_InitScreen();
V_Init2();
Expand Down

0 comments on commit 905cebf

Please sign in to comment.