summaryrefslogtreecommitdiff
path: root/src/filter.c
diff options
context:
space:
mode:
authorMichael McConville <mmcconville@mykolab.com>2015-12-08 21:00:39 -0500
committerWill Estes <westes575@gmail.com>2015-12-09 09:48:39 -0500
commitc53d722b0b4e81b08cfc2f9ff6675a7abe0de2c3 (patch)
tree4e19f81d30f1b2323c0a89a09c0d92359e713634 /src/filter.c
parentc03bef5411d3231f42445932d1971d656f020817 (diff)
downloadflex-git-c53d722b0b4e81b08cfc2f9ff6675a7abe0de2c3.tar.gz
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
Diffstat (limited to 'src/filter.c')
-rw-r--r--src/filter.c22
1 files changed, 10 insertions, 12 deletions
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 : "<stdout>");
- 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)) {