-
Notifications
You must be signed in to change notification settings - Fork 2
/
ft_lstclear.c
38 lines (34 loc) · 1.41 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: cado-car <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/31 13:36:01 by cado-car #+# #+# */
/* Updated: 2021/07/31 13:48:58 by cado-car ### ########lyon.fr */
/* */
/* ************************************************************************** */
/*
* 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.
* PARAMETERS
* #1. The adress of a pointer to an element.
* #2. The adress of the function used to delete the content of the element.
* RETURN VALUES
* -
*/
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *temp;
while (*lst != NULL)
{
temp = *lst;
*lst = (*lst)->next;
(*del)(temp->content);
free(temp);
}
}