Streamline.

This commit is contained in:
Christopher Kobayashi 2020-04-21 18:16:52 +09:00
parent 2e3aa7d8fd
commit bc9a1839a1
1 changed files with 9 additions and 5 deletions

View File

@ -56,12 +56,16 @@ int main(int argc, char **argv)
printf("%s: size is %li\n", argv[1], inputfile_stat.st_size);
file_buffer = calloc(1, inputfile_stat.st_size);
if (file_buffer != NULL)
printf("%s: read %li bytes into buffer\n", argv[1],
fread(file_buffer, 1, inputfile_stat.st_size, inputfile));
if (inputfile != NULL)
if (!file_buffer) {
printf("%s: could not allocate buffer\n");
fclose(inputfile);
return -1;
}
printf("%s: read %li bytes into buffer\n", argv[1],
fread(file_buffer, 1, inputfile_stat.st_size, inputfile));
fclose(inputfile);
/* consistency checks */
check = (file_buffer[0] << 8) + file_buffer[1];