1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Use xrealloc in cl65

Previously, xmalloc and xfree were used.
This commit is contained in:
Jesse Rosenstock 2020-07-02 22:24:57 +02:00 committed by Oliver Schmidt
parent 416adbce82
commit 527df094ca

View File

@ -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