Fix memory leaks with macro args

REPT blocks nested in macros (and possibly other cases) leaked
memory on every call. Unlike most other memory leaks, which would
be freed at the end of program execution if they were done properly,
those piled up the more compilation went on.
I believe memory usage could have started being fairly high on
large projects following the "one master file INCLUDEs all the rest"
so this may have actually been worth it.
This commit is contained in:
ISSOtm
2019-08-31 03:52:42 +02:00
parent a21cef7190
commit dfb3072381
3 changed files with 17 additions and 27 deletions

View File

@@ -128,13 +128,9 @@ static int32_t popcontext(void)
if (nCurrentStatus == STAT_isInclude)
fclose(pCurrentFile);
if (nCurrentStatus == STAT_isMacro) {
sym_FreeCurrentMacroArgs();
nLineNo += 1;
}
if (nCurrentStatus == STAT_isREPTBlock)
nLineNo += 1;
if (nCurrentStatus == STAT_isMacro
|| nCurrentStatus == STAT_isREPTBlock)
nLineNo++;
CurrentFlexHandle = pLastFile->FlexHandle;
strcpy((char *)tzCurrentFileName, (char *)pLastFile->tzFileName);
@@ -385,8 +381,8 @@ void fstk_RunString(char *s)
void fstk_RunRept(uint32_t count)
{
if (count) {
pushcontext();
sym_UseCurrentMacroArgs();
pushcontext();
sym_SetMacroArgID(nMacroCount++);
sym_UseNewMacroArgs();
nCurrentREPTBlockCount = count;