From c53d722b0b4e81b08cfc2f9ff6675a7abe0de2c3 Mon Sep 17 00:00:00 2001 From: Michael McConville Date: Tue, 8 Dec 2015 21:00:39 -0500 Subject: Removed flex_alloc; cleaned up style. The function flex_alloc() was just a wrapper around malloc(). Since this only added unclarity, and the flex_alloc() function is likely a legacy of olden times, remove it in favor of calls to malloc() directly. Style elements cleaned up: * superfluous spacing around parentheses * non-constant initialization in variable declarations * needless casts * almost all uses of assignments as subexpressions --- src/filter.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'src/filter.c') diff --git a/src/filter.c b/src/filter.c index 987366a..ac2f799 100644 --- a/src/filter.c +++ b/src/filter.c @@ -47,9 +47,9 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd, va_list ap; /* allocate and initialize new filter */ - f = (struct filter *) flex_alloc (sizeof (struct filter)); + f = malloc(sizeof(struct filter)); if (!f) - flexerror (_("flex_alloc failed (f) in filter_create_ext")); + flexerror(_("malloc failed (f) in filter_create_ext")); memset (f, 0, sizeof (*f)); f->filter_func = NULL; f->extra = NULL; @@ -66,11 +66,9 @@ struct filter *filter_create_ext (struct filter *chain, const char *cmd, /* allocate argv, and populate it with the argument list. */ max_args = 8; - f->argv = - (const char **) flex_alloc (sizeof (char *) * - (max_args + 1)); + f->argv = malloc(sizeof(char *) * (max_args + 1)); if (!f->argv) - flexerror (_("flex_alloc failed (f->argv) in filter_create_ext")); + flexerror(_("malloc failed (f->argv) in filter_create_ext")); f->argv[f->argc++] = cmd; va_start (ap, cmd); @@ -107,9 +105,9 @@ struct filter *filter_create_int (struct filter *chain, struct filter *f; /* allocate and initialize new filter */ - f = (struct filter *) flex_alloc (sizeof (struct filter)); + f = malloc(sizeof(struct filter)); if (!f) - flexerror (_("flex_alloc failed in filter_create_int")); + flexerror(_("malloc failed in filter_create_int")); memset (f, 0, sizeof (*f)); f->next = NULL; f->argc = 0; @@ -288,9 +286,9 @@ int filter_tee_header (struct filter *chain) fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n", outfilename ? outfilename : ""); - buf = (char *) flex_alloc (readsz); + buf = malloc(readsz); if (!buf) - flexerror (_("flex_alloc failed in filter_tee_header")); + flexerror(_("malloc failed in filter_tee_header")); while (fgets (buf, readsz, stdin)) { fputs (buf, to_c); if (write_header) @@ -349,9 +347,9 @@ int filter_fix_linedirs (struct filter *chain) if (!chain) return 0; - buf = (char *) flex_alloc (readsz); + buf = malloc(readsz); if (!buf) - flexerror (_("flex_alloc failed in filter_fix_linedirs")); + flexerror(_("malloc failed in filter_fix_linedirs")); while (fgets (buf, readsz, stdin)) { -- cgit v1.2.3