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