From 513ad7f75ff39c9fc065a56d39ae89d03a82e9be Mon Sep 17 00:00:00 2001 From: Marisa Heit Date: Fri, 11 Nov 2016 23:01:29 -0600 Subject: [PATCH] Use FString to store console atexit commands --- src/c_console.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index d4377682db..2f86228b70 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -115,8 +115,10 @@ static void ClearConsole (); struct GameAtExit { + GameAtExit(FString str) : Command(str) {} + GameAtExit *Next; - char Command[1]; + FString Command; }; static GameAtExit *ExitCmdList; @@ -551,16 +553,14 @@ CCMD (atexit) GameAtExit *record = ExitCmdList; while (record != NULL) { - Printf ("%s\n", record->Command); + Printf ("%s\n", record->Command.GetChars()); record = record->Next; } return; } for (int i = 1; i < argv.argc(); ++i) { - GameAtExit *record = (GameAtExit *)M_Malloc ( - sizeof(GameAtExit)+strlen(argv[i])); - strcpy (record->Command, argv[i]); + GameAtExit *record = new GameAtExit(argv[i]); record->Next = ExitCmdList; ExitCmdList = record; } @@ -582,8 +582,8 @@ void C_DeinitConsole () while (cmd != NULL) { GameAtExit *next = cmd->Next; - AddCommandString (cmd->Command); - M_Free (cmd); + AddCommandString (cmd->Command.LockBuffer()); + delete cmd; cmd = next; }