From bbec3ce5ff9da1b4b861e6bc82e0f24f013e6852 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Thu, 17 Aug 2017 19:27:49 +0000 Subject: combine malloc/memset into calloc. from Michael W. Bombardieri --- usr.bin/lex/filter.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'usr.bin/lex/filter.c') diff --git a/usr.bin/lex/filter.c b/usr.bin/lex/filter.c index 3ae77c450cf..558e038d2e6 100644 --- a/usr.bin/lex/filter.c +++ b/usr.bin/lex/filter.c @@ -1,4 +1,4 @@ -/* $OpenBSD: filter.c,v 1.7 2016/12/18 06:11:23 krw Exp $ */ +/* $OpenBSD: filter.c,v 1.8 2017/08/17 19:27:48 tedu Exp $ */ /* filter - postprocessing of flex output through filters */ @@ -50,10 +50,9 @@ filter_create_ext(struct filter * chain, const char *cmd, va_list ap; /* allocate and initialize new filter */ - f = malloc(sizeof(struct filter)); + f = calloc(sizeof(struct filter), 1); if (!f) - flexerror(_("malloc failed (f) in filter_create_ext")); - memset(f, 0, sizeof(*f)); + flexerror(_("calloc failed (f) in filter_create_ext")); f->filter_func = NULL; f->extra = NULL; f->next = NULL; @@ -103,10 +102,9 @@ filter_create_int(struct filter * chain, struct filter *f; /* allocate and initialize new filter */ - f = malloc(sizeof(struct filter)); + f = calloc(sizeof(struct filter), 1); if (!f) - flexerror(_("malloc failed in filter_create_int")); - memset(f, 0, sizeof(*f)); + flexerror(_("calloc failed in filter_create_int")); f->next = NULL; f->argc = 0; f->argv = NULL; -- cgit v1.2.3