summaryrefslogtreecommitdiff
path: root/src/platform/file.c
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-27 23:07:16 +1100
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-03-27 23:07:16 +1100
commitfe83372519e3ae8dd88ecfb4c67d484a1a5f13af (patch)
tree7c60d8840d457a95a0f01e9e2f0c55971948ce5f /src/platform/file.c
parentff907c6ffa7ed0a7c6ce938b40a6c223dd0a3b9d (diff)
brainsforming refined layout for renderer
Diffstat (limited to 'src/platform/file.c')
-rw-r--r--src/platform/file.c50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/platform/file.c b/src/platform/file.c
index ac5014d..6030620 100644
--- a/src/platform/file.c
+++ b/src/platform/file.c
@@ -63,31 +63,31 @@ str8_opt str8_from_file(arena *a, str8 path) {
}
FileData load_spv_file(const char *path) {
- FILE *f = fopen(path, "rb");
- if (f == NULL) {
- perror("Error opening file");
- return (FileData){NULL, 0};
- }
-
- fseek(f, 0, SEEK_END);
- long fsize = ftell(f);
- rewind(f);
-
- char *data = (char *)malloc(fsize);
- if (data == NULL) {
- perror("Memory allocation failed");
- fclose(f);
- return (FileData){NULL, 0};
- }
-
- size_t bytesRead = fread(data, 1, fsize, f);
- if (bytesRead < fsize) {
- perror("Failed to read the entire file");
- free(data);
- fclose(f);
- return (FileData){NULL, 0};
- }
+ FILE *f = fopen(path, "rb");
+ if (f == NULL) {
+ perror("Error opening file");
+ return (FileData){ NULL, 0 };
+ }
+
+ fseek(f, 0, SEEK_END);
+ long fsize = ftell(f);
+ rewind(f);
+ char *data = (char *)malloc(fsize);
+ if (data == NULL) {
+ perror("Memory allocation failed");
fclose(f);
- return (FileData){data, bytesRead};
+ return (FileData){ NULL, 0 };
+ }
+
+ size_t bytesRead = fread(data, 1, fsize, f);
+ if (bytesRead < fsize) {
+ perror("Failed to read the entire file");
+ free(data);
+ fclose(f);
+ return (FileData){ NULL, 0 };
+ }
+
+ fclose(f);
+ return (FileData){ data, bytesRead };
} \ No newline at end of file