From 4de08df981065bd4677bdd1631cb4f4fece10383 Mon Sep 17 00:00:00 2001 From: Thomas Rieg Date: Mon, 15 Dec 2025 15:56:19 +0100 Subject: [PATCH] fixed deadlock in ft_free --- srcs/ft_free.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/srcs/ft_free.c b/srcs/ft_free.c index 7759e30..22cddec 100644 --- a/srcs/ft_free.c +++ b/srcs/ft_free.c @@ -3,10 +3,10 @@ /* ::: :::::::: */ /* ft_free.c :+: :+: :+: */ /* +:+ +:+ +:+ */ -/* By: thrieg +#+ +:+ +#+ */ +/* By: thrieg < thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/11/19 15:44:05 by thrieg #+# #+# */ -/* Updated: 2025/12/13 06:52:01 by thrieg ### ########.fr */ +/* Updated: 2025/12/15 15:54:45 by thrieg ### ########.fr */ /* */ /* ************************************************************************** */ @@ -89,17 +89,14 @@ void free(void *ptr) pthread_mutex_unlock(&g_mut); return; } - else if (header->zone->type == E_SMALL) + else if (header->zone->type == E_SMALL || header->zone->type == E_TINY) { header->occupied = false; if (defrag_zone(header->zone)) - return; //zone munmaped, avoid all other logic on this memory - } - else if (header->zone->type == E_TINY) - { - header->occupied = false; - if (defrag_zone(header->zone)) - return; //zone munmaped, avoid all other logic on this memory + { + pthread_mutex_unlock(&g_mut); + return; // zone munmaped, avoid all other logic on this memory + } } else {