This code is the programming equivalent of filling a bathtub one teaspoon at a time while expanding the bathtub after each spoon. 😱
Instead of reading the file in chunks or pre-allocating memory, this monster allocates exactly ONE byte, reads ONE character, reallocates the ENTIRE array, and repeats for EVERY SINGLE CHARACTER. The malloc/realloc combo is basically begging the memory manager to have a nervous breakdown.
The performance would be so catastrophically bad that you could probably go make a sandwich between reading "Hello" and "World". It's like watching someone solve a maze by rebuilding the entire universe after each step.