mirror of
https://github.com/cc65/cc65.git
synced 2025-08-15 06:27:36 +00:00
Use xrealloc in cl65
Previously, xmalloc and xfree were used.
This commit is contained in:
committed by
Oliver Schmidt
parent
416adbce82
commit
527df094ca
@@ -231,12 +231,8 @@ static char* CmdAllocArg (const char* Arg, unsigned Len)
|
|||||||
static void CmdExpand (CmdDesc* Cmd)
|
static void CmdExpand (CmdDesc* Cmd)
|
||||||
/* Expand the argument vector */
|
/* Expand the argument vector */
|
||||||
{
|
{
|
||||||
unsigned NewMax = Cmd->ArgMax + 10;
|
Cmd->ArgMax += 10;
|
||||||
char** NewArgs = xmalloc (NewMax * sizeof (char*));
|
Cmd->Args = xrealloc (Cmd->Args, Cmd->ArgMax * sizeof (char*));
|
||||||
memcpy (NewArgs, Cmd->Args, Cmd->ArgMax * sizeof (char*));
|
|
||||||
xfree (Cmd->Args);
|
|
||||||
Cmd->Args = NewArgs;
|
|
||||||
Cmd->ArgMax = NewMax;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -324,12 +320,8 @@ static void CmdAddFile (CmdDesc* Cmd, const char* File)
|
|||||||
{
|
{
|
||||||
/* Expand the file vector if needed */
|
/* Expand the file vector if needed */
|
||||||
if (Cmd->FileCount == Cmd->FileMax) {
|
if (Cmd->FileCount == Cmd->FileMax) {
|
||||||
unsigned NewMax = Cmd->FileMax + 10;
|
Cmd->FileMax += 10;
|
||||||
char** NewFiles = xmalloc (NewMax * sizeof (char*));
|
Cmd->Files = xrealloc(Cmd->Files, Cmd->FileMax * sizeof(char*));
|
||||||
memcpy (NewFiles, Cmd->Files, Cmd->FileMax * sizeof (char*));
|
|
||||||
xfree (Cmd->Files);
|
|
||||||
Cmd->Files = NewFiles;
|
|
||||||
Cmd->FileMax = NewMax;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the file name is not NULL (which is legal and is used to terminate
|
/* If the file name is not NULL (which is legal and is used to terminate
|
||||||
|
Reference in New Issue
Block a user