diff options
Diffstat (limited to 'src/utils/file.c')
-rw-r--r-- | src/utils/file.c | 16 |
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; } |