libft_old/extended_libft/ft_lstclear.c
Willem Haffmans 326f52308e all
2024-07-26 22:32:04 +02:00

33 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/07/05 18:42:05 by whaffman #+# #+# */
/* Updated: 2024/07/10 17:08:53 by whaffman ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *next;
if (!del || !lst)
return ;
while (*lst)
{
if ((*lst)->next)
next = (*lst)->next;
else
next = NULL;
del((*lst)->content);
free(*lst);
*lst = next;
}
}