Portable print function using inttypes, multiplication
This commit is contained in:
parent
a663ce2044
commit
aec860a6b8
4 changed files with 48 additions and 10 deletions
11
src/main.c
11
src/main.c
|
@ -56,10 +56,10 @@ char* load_file_string(StringView path)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
if (fseek(stream, 0, SEEK_SET)) {
|
||||
perror("fseek");
|
||||
return NULL;
|
||||
}
|
||||
if (fseek(stream, 0, SEEK_SET)) {
|
||||
perror("fseek");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
char* buffer = malloc(length + 1);
|
||||
if (buffer == NULL) {
|
||||
|
@ -68,9 +68,8 @@ char* load_file_string(StringView path)
|
|||
}
|
||||
|
||||
size_t objects_read = fread(buffer, 1, length, stream);
|
||||
if (objects_read != length) {
|
||||
if (objects_read != (size_t) length) {
|
||||
fprintf(stderr, "Fatal Error: Failed read %li bytes from script file, got only %li\n", length, objects_read);
|
||||
;
|
||||
free(buffer);
|
||||
return NULL;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue