Portable print function using inttypes, multiplication

This commit is contained in:
vegowotenks 2024-10-08 23:24:25 +02:00
parent a663ce2044
commit aec860a6b8
4 changed files with 48 additions and 10 deletions

View file

@ -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;
}