summaryrefslogtreecommitdiff
path: root/src/utils/file.c
diff options
context:
space:
mode:
authorA404M <ahmadmahmoudiprogrammer@gmail.com>2025-02-08 08:54:04 +0330
committerA404M <ahmadmahmoudiprogrammer@gmail.com>2025-02-08 08:54:04 +0330
commit964c7178a371f79123d54a43671375f5c0ceb7e4 (patch)
tree3d4b2fe193e8bfd9b880014a8895c28b832e593a /src/utils/file.c
parent3adb71cebdec10823af28074a631bf929401e7c4 (diff)
better errors
Diffstat (limited to 'src/utils/file.c')
-rw-r--r--src/utils/file.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/utils/file.c b/src/utils/file.c
index c2dd614..f2244bf 100644
--- a/src/utils/file.c
+++ b/src/utils/file.c
@@ -5,6 +5,11 @@
#include <stddef.h>
#include <stdio.h>
+size_t fileCodes_capacity = 0;
+char **fileCodes = NULL;
+const char **fileCodes_names = 0;
+size_t fileCodes_length = 0;
+
char *readWholeFile(const char *filePath) {
FILE *file = fopen(filePath, "r");
@@ -23,5 +28,16 @@ char *readWholeFile(const char *filePath) {
fclose(file);
+ if (fileCodes_capacity == fileCodes_length) {
+ fileCodes_capacity += fileCodes_capacity / 2 + 1;
+ fileCodes =
+ a404m_realloc(fileCodes, fileCodes_capacity * sizeof(*fileCodes));
+ fileCodes_names = a404m_realloc(
+ fileCodes_names, fileCodes_capacity * sizeof(*fileCodes_names));
+ }
+ fileCodes[fileCodes_length] = str;
+ fileCodes_names[fileCodes_length] = filePath;
+ fileCodes_length += 1;
+
return str;
}