mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Use new allocation for expanding \#
This commit is contained in:
@@ -31,7 +31,7 @@ struct Expansion {
|
|||||||
std::optional<std::string> name;
|
std::optional<std::string> name;
|
||||||
union {
|
union {
|
||||||
char const *unowned;
|
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;
|
} contents;
|
||||||
size_t size; // Length of the contents
|
size_t size; // Length of the contents
|
||||||
size_t offset; // Cursor into the contents
|
size_t offset; // Cursor into the contents
|
||||||
|
|||||||
@@ -517,7 +517,7 @@ void lexer_CheckRecursionDepth()
|
|||||||
static void freeExpansion(Expansion &expansion)
|
static void freeExpansion(Expansion &expansion)
|
||||||
{
|
{
|
||||||
if (expansion.owned)
|
if (expansion.owned)
|
||||||
free(expansion.contents.owned);
|
delete [] expansion.contents.owned;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isMacroChar(char c)
|
static bool isMacroChar(char c)
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ char const *macro_GetAllArgs()
|
|||||||
for (uint32_t i = macroArgs->shift; i < nbArgs; i++)
|
for (uint32_t i = macroArgs->shift; i < nbArgs; i++)
|
||||||
len += macroArgs->args[i].length() + 1; // 1 for comma
|
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;
|
char *ptr = str;
|
||||||
|
|
||||||
if (!str)
|
if (!str)
|
||||||
|
|||||||
Reference in New Issue
Block a user