moved the memset for perturb patern outside of the lock in the free function

This commit is contained in:
Thomas Rieg 2025-12-08 15:54:25 +01:00
parent 6d84b2f72a
commit 442063daae

View file

@ -6,7 +6,7 @@
/* By: thrieg < thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2025/11/19 15:44:05 by thrieg #+# #+# */
/* Updated: 2025/12/08 15:34:11 by thrieg ### ########.fr */
/* Updated: 2025/12/08 15:53:31 by thrieg ### ########.fr */
/* */
/* ************************************************************************** */
@ -104,7 +104,7 @@ void free(void *ptr)
pthread_mutex_unlock(&g_mut);
return; // we didn't allocate this ptr
}
pthread_mutex_unlock(&g_mut);
if (g_state.patern)
ft_memset(ptr, g_state.patern ^ 0xFF, header->size); // doesn't need to lock because we only modify the user pointer and the user doesn't have accces to it yet
pthread_mutex_unlock(&g_mut);
}