Skip to content

Commit

Permalink
Allocate just enough to read the input file.
Browse files Browse the repository at this point in the history
  • Loading branch information
icculus committed Feb 19, 2009
1 parent 9c33281 commit e4e7b5e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions utils/preprocess.c
Expand Up @@ -210,8 +210,13 @@ int main(int argc, char **argv)
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);
Expand Down

0 comments on commit e4e7b5e

Please sign in to comment.