From 527df094caf40db07ac14f7591c8cf91f6d1a511 Mon Sep 17 00:00:00 2001 From: Jesse Rosenstock Date: Thu, 2 Jul 2020 22:24:57 +0200 Subject: [PATCH] Use xrealloc in cl65 Previously, xmalloc and xfree were used. --- src/cl65/main.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/cl65/main.c b/src/cl65/main.c index e7b9d5344..f75200c89 100644 --- a/src/cl65/main.c +++ b/src/cl65/main.c @@ -231,12 +231,8 @@ static char* CmdAllocArg (const char* Arg, unsigned Len) static void CmdExpand (CmdDesc* Cmd) /* Expand the argument vector */ { - unsigned NewMax = Cmd->ArgMax + 10; - char** NewArgs = xmalloc (NewMax * sizeof (char*)); - memcpy (NewArgs, Cmd->Args, Cmd->ArgMax * sizeof (char*)); - xfree (Cmd->Args); - Cmd->Args = NewArgs; - Cmd->ArgMax = NewMax; + Cmd->ArgMax += 10; + Cmd->Args = xrealloc (Cmd->Args, Cmd->ArgMax * sizeof (char*)); } @@ -324,12 +320,8 @@ static void CmdAddFile (CmdDesc* Cmd, const char* File) { /* Expand the file vector if needed */ if (Cmd->FileCount == Cmd->FileMax) { - unsigned NewMax = Cmd->FileMax + 10; - char** NewFiles = xmalloc (NewMax * sizeof (char*)); - memcpy (NewFiles, Cmd->Files, Cmd->FileMax * sizeof (char*)); - xfree (Cmd->Files); - Cmd->Files = NewFiles; - Cmd->FileMax = NewMax; + Cmd->FileMax += 10; + Cmd->Files = xrealloc(Cmd->Files, Cmd->FileMax * sizeof(char*)); } /* If the file name is not NULL (which is legal and is used to terminate