From 964c7178a371f79123d54a43671375f5c0ceb7e4 Mon Sep 17 00:00:00 2001 From: A404M Date: Sat, 8 Feb 2025 08:54:04 +0330 Subject: better errors --- src/utils/file.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'src/utils/file.c') 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 #include +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; } -- cgit v1.2.3