Use calloc() instead of zeroing the memory our own.
This commit is contained in:
parent
c84efdca04
commit
5f17c1e2b2
@ -154,8 +154,7 @@ Config_spec:
|
||||
CPU Save_id
|
||||
= {
|
||||
struct cputype *cp =
|
||||
(struct cputype *)malloc(sizeof (struct cputype));
|
||||
memset(cp, 0, sizeof(*cp));
|
||||
(struct cputype *)calloc(1, sizeof (struct cputype));
|
||||
cp->cpu_name = $2;
|
||||
SLIST_INSERT_HEAD(&cputype, cp, cpu_next);
|
||||
} |
|
||||
@ -336,8 +335,7 @@ newfile(char *name)
|
||||
{
|
||||
struct files_name *nl;
|
||||
|
||||
nl = (struct files_name *) malloc(sizeof *nl);
|
||||
bzero(nl, sizeof *nl);
|
||||
nl = (struct files_name *) calloc(1, sizeof *nl);
|
||||
nl->f_name = name;
|
||||
STAILQ_INSERT_TAIL(&fntab, nl, f_next);
|
||||
}
|
||||
@ -370,8 +368,7 @@ newdev(char *name)
|
||||
return;
|
||||
}
|
||||
|
||||
np = (struct device *) malloc(sizeof *np);
|
||||
memset(np, 0, sizeof(*np));
|
||||
np = (struct device *) calloc(1, sizeof *np);
|
||||
np->d_name = name;
|
||||
STAILQ_INSERT_TAIL(&dtab, np, d_next);
|
||||
}
|
||||
@ -420,8 +417,7 @@ newopt(struct opt_head *list, char *name, char *value)
|
||||
return;
|
||||
}
|
||||
|
||||
op = (struct opt *)malloc(sizeof (struct opt));
|
||||
memset(op, 0, sizeof(*op));
|
||||
op = (struct opt *)calloc(1, sizeof (struct opt));
|
||||
op->op_name = name;
|
||||
op->op_ownfile = 0;
|
||||
op->op_value = value;
|
||||
|
@ -518,8 +518,7 @@ remember(const char *file)
|
||||
return;
|
||||
}
|
||||
}
|
||||
hl = malloc(sizeof(*hl));
|
||||
bzero(hl, sizeof(*hl));
|
||||
hl = calloc(1, sizeof(*hl));
|
||||
hl->h_name = s;
|
||||
hl->h_next = htab;
|
||||
htab = hl;
|
||||
|
@ -97,8 +97,7 @@ new_fent(void)
|
||||
{
|
||||
struct file_list *fp;
|
||||
|
||||
fp = (struct file_list *) malloc(sizeof *fp);
|
||||
bzero(fp, sizeof *fp);
|
||||
fp = (struct file_list *) calloc(1, sizeof *fp);
|
||||
STAILQ_INSERT_TAIL(&ftab, fp, f_next);
|
||||
return (fp);
|
||||
}
|
||||
|
@ -69,8 +69,7 @@ options(void)
|
||||
|
||||
/* Fake the cpu types as options. */
|
||||
SLIST_FOREACH(cp, &cputype, cpu_next) {
|
||||
op = (struct opt *)malloc(sizeof(*op));
|
||||
memset(op, 0, sizeof(*op));
|
||||
op = (struct opt *)calloc(1, sizeof(*op));
|
||||
op->op_name = ns(cp->cpu_name);
|
||||
SLIST_INSERT_HEAD(&opt, op, op_next);
|
||||
}
|
||||
@ -84,8 +83,7 @@ options(void)
|
||||
printf("warning: maxusers > %d (%d)\n", users.u_max, maxusers);
|
||||
|
||||
/* Fake MAXUSERS as an option. */
|
||||
op = (struct opt *)malloc(sizeof(*op));
|
||||
memset(op, 0, sizeof(*op));
|
||||
op = (struct opt *)calloc(1, sizeof(*op));
|
||||
op->op_name = ns("MAXUSERS");
|
||||
snprintf(buf, sizeof(buf), "%d", maxusers);
|
||||
op->op_value = ns(buf);
|
||||
@ -200,8 +198,7 @@ do_option(char *name)
|
||||
inw, basefile, ol->o_file);
|
||||
tidy++;
|
||||
} else {
|
||||
op = (struct opt *) malloc(sizeof *op);
|
||||
bzero(op, sizeof(*op));
|
||||
op = (struct opt *) calloc(1, sizeof *op);
|
||||
op->op_name = inw;
|
||||
op->op_value = invalue;
|
||||
SLIST_INSERT_HEAD(&op_head, op, op_next);
|
||||
@ -227,8 +224,7 @@ do_option(char *name)
|
||||
|
||||
if (value && !seen) {
|
||||
/* New option appears */
|
||||
op = (struct opt *) malloc(sizeof *op);
|
||||
bzero(op, sizeof(*op));
|
||||
op = (struct opt *) calloc(1, sizeof *op);
|
||||
op->op_name = ns(name);
|
||||
op->op_value = value ? ns(value) : NULL;
|
||||
SLIST_INSERT_HEAD(&op_head, op, op_next);
|
||||
@ -339,8 +335,7 @@ read_options(void)
|
||||
}
|
||||
}
|
||||
|
||||
po = (struct opt_list *) malloc(sizeof *po);
|
||||
bzero(po, sizeof(*po));
|
||||
po = (struct opt_list *) calloc(1, sizeof *po);
|
||||
po->o_name = this;
|
||||
po->o_file = val;
|
||||
SLIST_INSERT_HEAD(&otab, po, o_next);
|
||||
|
Loading…
Reference in New Issue
Block a user