Remove xcalloc() and convert its callers to xzalloc(). About half of them

were using "1" as one of the arguments anyway, and as for the rest a multiply
and a push isn't noticeably bigger than pushing two arguments on the stack.
This commit is contained in:
Rob Landley
2006-08-03 20:07:35 +00:00
parent 86b4d64aa3
commit 081e38483e
15 changed files with 22 additions and 32 deletions

View File

@@ -135,7 +135,7 @@ static void cut_line_by_chars(const char *line)
{
int c, l;
/* set up a list so we can keep track of what's been printed */
char *printed = xcalloc(strlen(line), sizeof(char));
char *printed = xzalloc(strlen(line));
/* print the chars specified in each cut list */
for (c = 0; c < nlists; c++) {
@@ -172,7 +172,7 @@ static void cut_line_by_fields(char *line)
}
/* set up a list so we can keep track of what's been printed */
printed = xcalloc(strlen(line), sizeof(char));
printed = xzalloc(strlen(line));
/* process each list on this line, for as long as we've got a line to process */
for (c = 0; c < nlists && line; c++) {

View File

@@ -300,7 +300,7 @@ static struct dnode **dnalloc(int num)
if (num < 1)
return (NULL);
p = (struct dnode **) xcalloc((size_t) num, (size_t) (sizeof(struct dnode *)));
p = (struct dnode **) xzalloc(num * sizeof(struct dnode *));
return (p);
}

View File

@@ -120,7 +120,7 @@ static struct sort_key *add_key(void)
{
struct sort_key **pkey=&key_list;
while(*pkey) pkey=&((*pkey)->next_key);
return *pkey=xcalloc(1,sizeof(struct sort_key));
return *pkey = xzalloc(sizeof(struct sort_key));
}
#define GET_LINE(fp) (global_flags&FLAG_z) ? bb_get_chunk_from_file(fp,NULL) \