From b49f582c5c9f707ba13e37fd2a0f6ab3bb22b2a6 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Thu, 2 Feb 2023 16:53:25 +0100 Subject: [PATCH] defined why2_clean_memory it should be complete now, time to implement it --- src/core/lib/utils/memory.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/core/lib/utils/memory.c b/src/core/lib/utils/memory.c index 20bdffa..ad9c812 100644 --- a/src/core/lib/utils/memory.c +++ b/src/core/lib/utils/memory.c @@ -137,4 +137,20 @@ void why2_free(void *pointer) if (node != NULL) remove_node(node); //REMOVE FROM LIST IF FOUND free(pointer); +} + +void why2_clean_memory(char *identifier) +{ + if (head == NULL) return; //LIST IS EMPTY + + node_t *buffer = head; + + while (buffer -> next != NULL) //GO TROUGH LIST + { + if (buffer -> identifier == identifier) remove_node(buffer); + + buffer = buffer -> next; + } + + if (buffer -> identifier == identifier) remove_node(buffer); //LAST NODE } \ No newline at end of file