diff --git a/include/asm/lexer.hpp b/include/asm/lexer.hpp index 940595d3..d6c16b1b 100644 --- a/include/asm/lexer.hpp +++ b/include/asm/lexer.hpp @@ -31,7 +31,7 @@ struct Expansion { std::optional name; union { char const *unowned; - char *owned; // Non-`const` only so it can be `free()`d + char *owned; // Non-`const` only so it can be `delete []`d } contents; size_t size; // Length of the contents size_t offset; // Cursor into the contents diff --git a/src/asm/lexer.cpp b/src/asm/lexer.cpp index 5780d506..94862a25 100644 --- a/src/asm/lexer.cpp +++ b/src/asm/lexer.cpp @@ -517,7 +517,7 @@ void lexer_CheckRecursionDepth() static void freeExpansion(Expansion &expansion) { if (expansion.owned) - free(expansion.contents.owned); + delete [] expansion.contents.owned; } static bool isMacroChar(char c) diff --git a/src/asm/macro.cpp b/src/asm/macro.cpp index 19be7182..9bb4862d 100644 --- a/src/asm/macro.cpp +++ b/src/asm/macro.cpp @@ -63,7 +63,7 @@ char const *macro_GetAllArgs() for (uint32_t i = macroArgs->shift; i < nbArgs; i++) len += macroArgs->args[i].length() + 1; // 1 for comma - char *str = (char *)malloc(len + 1); // 1 for '\0' + char *str = new char[len + 1]; // 1 for '\0' char *ptr = str; if (!str)