-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstdel.c
37 lines (33 loc) · 1.28 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
36
37
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdel.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mwilliam <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/03 12:16:42 by mwilliam #+# #+# */
/* Updated: 2016/12/03 12:16:44 by mwilliam ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** Takes a link's pointer address and frees the memory of that link
** and every successor using del and free
*/
void ft_lstdel(t_list **alst, void (*del)(void *, size_t))
{
t_list *link;
t_list *next_link;
link = *alst;
if (link && del)
{
while (link)
{
next_link = link->next;
del(link->content, link->content_size);
free(link);
link = next_link;
}
*alst = NULL;
}
}