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