From 7d79ee29ebed2cf535f1eb8f84670bd4137cf0ae Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Mon, 6 Feb 2023 16:52:08 +0100 Subject: [PATCH 1/3] added some useless NULL check --- src/core/lib/utils/memory.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/core/lib/utils/memory.c b/src/core/lib/utils/memory.c index 730d9a6..429239d 100644 --- a/src/core/lib/utils/memory.c +++ b/src/core/lib/utils/memory.c @@ -90,6 +90,8 @@ void remove_node(node_t *node) node_t *get_node(void *pointer) { + if (head == NULL) return NULL; //EMPTY LIST + node_t *buffer = head; while (buffer -> next != NULL) { From bdd947fc64eaba784505cae805a2b4196814438e Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Mon, 6 Feb 2023 16:58:02 +0100 Subject: [PATCH 2/3] defined why2_opendir fuck if this is gonna be painful as the last memory functions, I'm gonna hang myself --- src/core/lib/utils/memory.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/core/lib/utils/memory.c b/src/core/lib/utils/memory.c index 429239d..9c1628d 100644 --- a/src/core/lib/utils/memory.c +++ b/src/core/lib/utils/memory.c @@ -162,6 +162,15 @@ void *why2_fdopen(int file, char *modes) return opened; } +void *why2_opendir(char *name) +{ + void *opened = opendir(name); + + push_to_list(opened, OPENDIR); + + return opened; +} + void why2_deallocate(void *pointer) { //VARIABLES From 44941a1b055e4f6dab1b3fd9bf7e044e87717b01 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Mon, 6 Feb 2023 16:59:31 +0100 Subject: [PATCH 3/3] implemented why2_opendir shit it works no memery lekz LET'S FUCKING GO --- src/logger/lib/logger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/logger/lib/logger.c b/src/logger/lib/logger.c index f12dc9c..3dd2049 100644 --- a/src/logger/lib/logger.c +++ b/src/logger/lib/logger.c @@ -59,7 +59,7 @@ why2_log_file why2_init_logger(char *directoryPath) } //COUNT HOW MANY LOGS WERE GENERATED THIS DAY - dir = opendir(directoryPath); + dir = why2_opendir(directoryPath); while ((entry = readdir(dir)) != NULL) { if (entry -> d_type == DT_REG) @@ -101,7 +101,7 @@ why2_log_file why2_init_logger(char *directoryPath) why2_deallocate(dateBuffer); why2_deallocate(latestBuffer); why2_deallocate(latestFilePath); - closedir(dir); + why2_deallocate(dir); why2_reset_memory_identifier();