31 lines
1.3 KiB
C
Executable file
31 lines
1.3 KiB
C
Executable file
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_lstclear_bonus.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: thrieg <thrieg@student.42mulhouse.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2024/10/16 13:00:50 by thrieg #+# #+# */
|
|
/* Updated: 2025/02/16 19:03:54 by thrieg ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include "libft.h"
|
|
|
|
//returns without doing anything if lst or del are NULL, this is dumb because we
|
|
//can't report the error given the prototyping but I'm not taking any risk for
|
|
//my 3th retry...
|
|
void ft_lstclear(t_list **lst, void (*del)(void *))
|
|
{
|
|
t_list *next;
|
|
|
|
if (!lst || !del)
|
|
return ;
|
|
while (*lst)
|
|
{
|
|
next = (*lst)->next;
|
|
del((*lst)->content);
|
|
free(*lst);
|
|
*lst = next;
|
|
}
|
|
}
|