Files
42_INT_01_libft/srcs/ft_lstremove_next.delete

31 lines
1.2 KiB
Plaintext

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstremove_next.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: simplonco <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/23 21:42:05 by simplonco #+# #+# */
/* Updated: 2022/03/23 21:42:55 by simplonco ### ########.fr */
/* */
/* ************************************************************************** */
/*
* remove the next element of the list, delete its content, and free it
* then rejoin the list without this element
*/
#include "libft.h"
void ft_lstremove_next(t_list *lst, void (*del)(void *))
{
t_list *next_tmp;
if (!lst || !lst->next || !del)
return ;
next_tmp = lst->next->next;
del(lst->next->content);
free(lst->next);
lst->next = next_tmp;
}