Some general reworking, error handling

This commit is contained in:
2024-12-03 00:04:40 +00:00
parent 623b3acc1f
commit 9bbfa7d2cd
4 changed files with 36 additions and 7 deletions

8
lib.c
View File

@@ -33,6 +33,14 @@ char *fread_all(FILE *fp)
size_t used, available;
} buffer = {calloc(CHUNK_SIZE, sizeof(*buffer.data)), 0, CHUNK_SIZE};
if (!buffer.data)
{
print_error(
"[internal]", 0, 0,
"ERROR: Out of Memory (could not allocate buffer in fread_all)");
return NULL;
}
size_t acc = 0, bytes_read = 0;
while ((bytes_read = fread(buffer.data + acc, sizeof(*buffer.data),
CHUNK_SIZE, fp)) != 0)