-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstdel.c
35 lines (32 loc) · 1.27 KB
/
ft_lstdel.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdel.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: dlevy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/12/02 14:38:04 by dlevy #+# #+# */
/* Updated: 2014/12/02 17:42:12 by dlevy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
t_list *tmp;
t_list *tmptwo;
if (!alst || !del)
return ;
if (!(tmp = malloc(sizeof(t_list))))
return ;
tmp = *alst;
while (tmp->next != NULL)
{
tmptwo = tmp;
del(tmptwo->content, tmptwo->content_size);
free(tmptwo);
tmp = tmp->next;
}
del(tmp->content, tmptwo->content_size);
free(tmp);
*alst = NULL;
}