42-archive/42sh/libft/src/dlst/ft_dlstdelone.c
2017-03-17 00:05:10 +01:00

34 lines
1.2 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlst_delone.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/07 13:27:13 by jhalford #+# #+# */
/* Updated: 2016/11/14 17:52:58 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_dlstdelone(t_dlist **alst, void (*del)(void *, size_t))
{
t_dlist *tmp;
tmp = *alst;
if (tmp)
{
if (del)
(*del)(tmp->content, tmp->content_size);
if (tmp->next)
tmp->next->prev = tmp->prev;
if (tmp->prev)
tmp->prev->next = tmp->next;
if (tmp->prev)
*alst = tmp->prev;
else
*alst = tmp->next;
free(tmp);
}
}