diff options
-rw-r--r-- | usr.sbin/config/config.y | 12 | ||||
-rw-r--r-- | usr.sbin/config/main.c | 3 | ||||
-rw-r--r-- | usr.sbin/config/mkmakefile.c | 3 | ||||
-rw-r--r-- | usr.sbin/config/mkoptions.c | 15 |
4 files changed, 11 insertions, 22 deletions
diff --git a/usr.sbin/config/config.y b/usr.sbin/config/config.y index 770833d..adb6ff4 100644 --- a/usr.sbin/config/config.y +++ b/usr.sbin/config/config.y @@ -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; diff --git a/usr.sbin/config/main.c b/usr.sbin/config/main.c index 4929f56..a87f3d7 100644 --- a/usr.sbin/config/main.c +++ b/usr.sbin/config/main.c @@ -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; diff --git a/usr.sbin/config/mkmakefile.c b/usr.sbin/config/mkmakefile.c index 10e7ba8..93323ec 100644 --- a/usr.sbin/config/mkmakefile.c +++ b/usr.sbin/config/mkmakefile.c @@ -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); } diff --git a/usr.sbin/config/mkoptions.c b/usr.sbin/config/mkoptions.c index d757815..c4bd624 100644 --- a/usr.sbin/config/mkoptions.c +++ b/usr.sbin/config/mkoptions.c @@ -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 @@ next: } } - 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); |