Hello,
Two instances of memset() can be removed in lex if calloc() is
used instead of malloc().
- Michael
Index: filter.c
===================================================================
RCS file: /cvs/src/usr.bin/lex/filter.c,v
retrieving revision 1.7
diff -u -p -u -r1.7 filter.c
--- filter.c 18 Dec 2016 06:11:23 -0000 1.7
+++ filter.c 17 Aug 2017 05:46:13 -0000
@@ -50,10 +50,9 @@ filter_create_ext(struct filter * chain,
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;