mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user