Allocate just enough to read the input file.
--- a/utils/preprocess.c Thu Feb 19 01:46:18 2009 -0500
+++ b/utils/preprocess.c Thu Feb 19 03:09:26 2009 -0500
@@ -210,8 +210,13 @@
printf(" ... fopen('%s') failed.\n", infile);
else
{
- char *buf = (char *) malloc(1000000);
- int rc = fread(buf, 1, 1000000, io);
+ fseek(io, 0, SEEK_END);
+ long fsize = ftell(io);
+ fseek(io, 0, SEEK_SET);
+ if (fsize == -1)
+ fsize = 1000000;
+ char *buf = (char *) malloc(fsize);
+ const int rc = fread(buf, 1, fsize, io);
fclose(io);
if (rc == EOF)
printf(" ... fread('%s') failed.\n", infile);