diff --git a/docs/rh-log.txt b/docs/rh-log.txt index 869e645d8..1e12bdde7 100644 --- a/docs/rh-log.txt +++ b/docs/rh-log.txt @@ -1,3 +1,10 @@ +June 5, 2008 +- Repositioned the declaration of the file string in D_DoomMain() so that it + won't be left around on the stack at exit. +- Fixed: PSymbol needs a virtual destructor so that PSymbolActionFunction can + free its Arguments. +- Symbols for native classes are now freed on exit. + June 4, 2008 - Removed the 8-character limit on endpic names from the parser. (Though it might still be present in the texture manager; I don't remember.) diff --git a/src/d_main.cpp b/src/d_main.cpp index f6ed3955b..ab098dbc6 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2059,7 +2059,6 @@ void D_MultiExec (DArgs *list, bool usePullin) void D_DoomMain (void) { int p, flags; - FString file; char *v; const char *wad; DArgs *execFiles; @@ -2096,6 +2095,8 @@ void D_DoomMain (void) if (!(gameinfo.flags & GI_SHAREWARE)) { + FString file; + // [RH] zvox.wad - A wad I had intended to be automatically generated // from Q2's pak0.pak so the female and cyborg player could have // voices. I never got around to writing the utility to do it, though. @@ -2506,7 +2507,7 @@ void D_DoomMain (void) v = Args->CheckValue ("-loadgame"); if (v) { - file = v; + FString file(v); FixPathSeperator (file); DefaultExtension (file, ".zds"); G_LoadGame (file); diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index be0e8a6b6..537bf84d1 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -147,7 +147,10 @@ void PClass::StaticFreeData (PClass *type) } delete type; } - + else + { + type->Symbols.ReleaseSymbols(); + } } void ClassReg::RegisterClass () @@ -350,12 +353,22 @@ void PClass::FreeStateList () // Symbol tables ------------------------------------------------------------ +PSymbol::~PSymbol() +{ +} + PSymbolTable::~PSymbolTable () +{ + ReleaseSymbols(); +} + +void PSymbolTable::ReleaseSymbols() { for (unsigned int i = 0; i < Symbols.Size(); ++i) { delete Symbols[i]; } + Symbols.Clear(); } void PSymbolTable::SetParentTable (PSymbolTable *parent) diff --git a/src/dobjtype.h b/src/dobjtype.h index aae53970b..626c7c100 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -15,6 +15,8 @@ enum ESymbolType struct PSymbol { + virtual ~PSymbol(); + ESymbolType SymbolType; FName SymbolName; }; @@ -75,6 +77,9 @@ public: // not copied and will be freed when the symbol table is destroyed. PSymbol *AddSymbol (PSymbol *sym); + // Frees all symbols from this table. + void ReleaseSymbols(); + private: PSymbolTable *ParentSymbolTable; TArray Symbols; diff --git a/src/win32/i_main.cpp b/src/win32/i_main.cpp index 4585006ad..7101705f3 100644 --- a/src/win32/i_main.cpp +++ b/src/win32/i_main.cpp @@ -1204,7 +1204,12 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE nothing, LPSTR cmdline, int n // every allocation and deallocation. This will be slow, but it can be a // great help in finding problem areas. //_CrtSetDbgFlag (_CRTDBG_ALLOC_MEM_DF | _CRTDBG_CHECK_ALWAYS_DF); + + // Enable leak checking at exit. _CrtSetDbgFlag (_CrtSetDbgFlag(0) | _CRTDBG_LEAK_CHECK_DF); + + // Use this to break at a specific allocation number. + //_crtBreakAlloc = 5501; #endif DoMain (hInstance);