ft_printf/libft/ft_lstclear.c
2024-10-15 12:43:54 +02:00

33 lines
1.1 KiB
C

/* ************************************************************************** */
/* */
/* ::: o_ :::::: ::: */
/* ft_lstclear.c :+: / :+::+: :+: */
/* +:+ > +:++:+ +:+ */
/* By: whaffman <whaffman@student.codam.nl> +#+ +:+ +#++#++:++#++ */
/* +#+ +#+#+ +#++#+ +#+ \o/ */
/* Created: 2024/10/10 17:00:19 by whaffman #+#+# #+#+# #+# #+# | */
/* Updated: 2024/10/10 17:00:19 by whaffman ### ### ### ### / \ */
/* */
/* ************************************************************************** */
#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;
}
}