Use FString to store console atexit commands

This commit is contained in:
Marisa Heit 2016-11-11 23:01:29 -06:00
parent c5eb28d360
commit 513ad7f75f
1 changed files with 7 additions and 7 deletions

View File

@ -115,8 +115,10 @@ static void ClearConsole ();
struct GameAtExit struct GameAtExit
{ {
GameAtExit(FString str) : Command(str) {}
GameAtExit *Next; GameAtExit *Next;
char Command[1]; FString Command;
}; };
static GameAtExit *ExitCmdList; static GameAtExit *ExitCmdList;
@ -551,16 +553,14 @@ CCMD (atexit)
GameAtExit *record = ExitCmdList; GameAtExit *record = ExitCmdList;
while (record != NULL) while (record != NULL)
{ {
Printf ("%s\n", record->Command); Printf ("%s\n", record->Command.GetChars());
record = record->Next; record = record->Next;
} }
return; return;
} }
for (int i = 1; i < argv.argc(); ++i) for (int i = 1; i < argv.argc(); ++i)
{ {
GameAtExit *record = (GameAtExit *)M_Malloc ( GameAtExit *record = new GameAtExit(argv[i]);
sizeof(GameAtExit)+strlen(argv[i]));
strcpy (record->Command, argv[i]);
record->Next = ExitCmdList; record->Next = ExitCmdList;
ExitCmdList = record; ExitCmdList = record;
} }
@ -582,8 +582,8 @@ void C_DeinitConsole ()
while (cmd != NULL) while (cmd != NULL)
{ {
GameAtExit *next = cmd->Next; GameAtExit *next = cmd->Next;
AddCommandString (cmd->Command); AddCommandString (cmd->Command.LockBuffer());
M_Free (cmd); delete cmd;
cmd = next; cmd = next;
} }