From f4975050e43fd3b2f3fb9b8127d7bfdfa35ceb55 Mon Sep 17 00:00:00 2001 From: ENGO150 Date: Fri, 3 Feb 2023 16:43:04 +0100 Subject: [PATCH] added 'bypass' to why2_clean_memory if you pass DEFAULT_IDENTIFIER as parameter every node is deallocated --- src/core/lib/utils/memory.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/core/lib/utils/memory.c b/src/core/lib/utils/memory.c index 45e09a8..ccee4cf 100644 --- a/src/core/lib/utils/memory.c +++ b/src/core/lib/utils/memory.c @@ -144,15 +144,16 @@ void why2_clean_memory(char *identifier) if (head == NULL) return; //LIST IS EMPTY node_t *buffer = head; + why2_bool force_deallocating = identifier == why2_get_default_memory_identifier(); while (buffer -> next != NULL) //GO TROUGH LIST { - if (buffer -> identifier == identifier) why2_free(buffer -> pointer); + if (buffer -> identifier == identifier || force_deallocating) why2_free(buffer -> pointer); buffer = buffer -> next; } - if (buffer -> identifier == identifier) why2_free(buffer -> pointer); //LAST NODE + if (buffer -> identifier == identifier || force_deallocating) why2_free(buffer -> pointer); //LAST NODE why2_reset_memory_identifier(); //THIS WILL CAUSE SEGFAULT IF YOU DIDN'T USE why2_set_memory_identifier } \ No newline at end of file