42-archive/libftasm/src/lst/ft_lst_delif.c
2016-11-16 18:33:01 +01:00

37 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst_delif.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jhalford <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/04 11:09:12 by jhalford #+# #+# */
/* Updated: 2016/11/16 18:23:24 by jhalford ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lst_delif(
t_list **alst,
void *data_ref,
int (*cmp)(),
void (*del)(void *, size_t))
{
t_list *tmp;
t_list **indirect;
indirect = alst;
while (*indirect)
{
if ((*cmp)((*indirect)->content, data_ref) == 0)
{
tmp = (*indirect);
(*indirect) = (*indirect)->next;
ft_printf("free'd at %p\n", tmp);
(*del)(tmp->content, tmp->content_size);
}
else
indirect = &(*indirect)->next;
}
}