for(i=0;(count = fread(&fbuf[i],1,1024,cfile)) == 1024;i+=1024) { if ((fbuf = realloc(fbuf,i+1024+1024)) == NULL) { fprintf(stderr,"Could not allocate memory for config file, barfing.\n"); exit(EXIT_FAILURE); } } /* If NOT the end-of-file, we must have had an error of some sort, barf and die */ if (!feof(cfile)) { fprintf(stderr, "An error occurred while reading the config file\n"); exit(EXIT_FAILURE); } /* Terminate it with a NULL */ fbuf[i+count] = '\0';