summaryrefslogtreecommitdiff
path: root/src/filter.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/filter.c')
-rw-r--r--src/filter.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/filter.c b/src/filter.c
index ed3bfe3..35b80a9 100644
--- a/src/filter.c
+++ b/src/filter.c
@@ -230,8 +230,7 @@ int filter_tee_header (struct filter *chain)
* header file at the same time.
*/
- const int readsz = 512;
- char *buf;
+ char buf[512];
int to_cfd = -1;
FILE *to_c = NULL, *to_h = NULL;
bool write_header;
@@ -283,10 +282,7 @@ int filter_tee_header (struct filter *chain)
fprintf (to_c, "m4_define( [[M4_YY_OUTFILE_NAME]],[[%s]])m4_dnl\n",
outfilename ? outfilename : "<stdout>");
- buf = malloc((size_t) readsz);
- if (!buf)
- flexerror(_("malloc failed in filter_tee_header"));
- while (fgets (buf, readsz, stdin)) {
+ while (fgets (buf, sizeof buf, stdin)) {
fputs (buf, to_c);
if (write_header)
fputs (buf, to_h);
@@ -336,8 +332,8 @@ int filter_tee_header (struct filter *chain)
*/
int filter_fix_linedirs (struct filter *chain)
{
- char *buf;
- const size_t readsz = 512;
+ char buf[512];
+ const size_t readsz = sizeof buf;
int lineno = 1;
bool in_gen = true; /* in generated code */
bool last_was_blank = false;
@@ -345,10 +341,6 @@ int filter_fix_linedirs (struct filter *chain)
if (!chain)
return 0;
- buf = malloc(readsz);
- if (!buf)
- flexerror(_("malloc failed in filter_fix_linedirs"));
-
while (fgets (buf, (int) readsz, stdin)) {
regmatch_t m[10];