Files
42_INT_10_cube3d/libs/libft/srcs/ft_lsterase.c
2022-05-04 14:38:34 +02:00

32 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lsterase.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: simplonco <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/24 15:31:16 by simplonco #+# #+# */
/* Updated: 2022/05/04 14:17:57 by pblagoje ### ########.fr */
/* */
/* ************************************************************************** */
/*
* erase an element in two-way list
* and rejoin the list
*/
#include "libft.h"
void ft_lsterase(t_list *lst, void (*del)(void *))
{
if (!lst || !del)
return ;
del(lst->content);
if (lst->prev)
lst->prev->next = lst->next;
if (lst->next)
lst->next->prev = lst->prev;
free(lst);
lst = NULL;
}