#include "filetree.h" #include void add_directory(struct dirnode *cur, struct dirnode *item) { // NOTE(feliix42): I'm aware that this is super inefficient, but who cares struct dirnode **items = realloc(cur->directories, (cur->num_dirs + 1) * sizeof(struct dirnode *)); if (!items) { fprintf(stderr, "\033[93m[error] Failed to allocate memory\033[0m\n"); return; } cur->directories = items; cur->directories[cur->num_dirs] = item; cur->num_dirs++; } void add_file(struct dirnode *cur, struct filenode *item) { // NOTE(feliix42): I'm aware that this is super inefficient, but who cares struct filenode **items = realloc(cur->files, (cur->num_files + 1) * sizeof(struct filenode *)); if (!items) { fprintf(stderr, "\033[93m[error] Failed to allocate memory\033[0m\n"); return; } cur->files = items; cur->files[cur->num_files] = item; cur->num_files++; }