-
Notifications
You must be signed in to change notification settings - Fork 12
/
ft_lstclear.c
38 lines (34 loc) · 1.36 KB
/
ft_lstclear.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
38
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: apuchill <apuchill@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/02/07 17:10:27 by apuchill #+# #+# */
/* Updated: 2020/02/19 14:04:03 by apuchill ### ########.fr */
/* */
/* ************************************************************************** */
/*
** LIBRARY: N/A
** SYNOPSIS: delete sequence of elements of list from a starting point
**
** DESCRIPTION:
** Deletes and frees the given element and every successor of that element,
** using the function ’del’ and free(3). Finally, the pointer to the list must
** be set to NULL.
*/
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *aux;
if (!*lst)
return ;
while (*lst)
{
aux = (*lst)->next;
ft_lstdelone(*lst, del);
*lst = aux;
}
*lst = 0;
}