-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstclear.c
43 lines (41 loc) · 1.62 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
39
40
41
42
43
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jamendoe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/13 13:27:41 by jamendoe #+# #+# */
/* Updated: 2022/11/13 13:27:45 by jamendoe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *clear;
if (!lst || !del)
return ((void) NULL);
clear = (*lst);
while (clear != NULL)
{
clear = clear->next;
del((*lst)->content);
free(*lst);
(*lst) = clear;
}
}
/*
Function name ft_lstclear
Prototype void ft_lstclear(t_list **lst, void (*del)(void*));
Turn in files -
Parameters lst: The address of a pointer to a node.
del: The address of the function used to delete
the content of the node.
Return value None
External functs. free
Description Deletes and frees the given node and every
successor of that node, using the function ’del’
and free(3).
Finally, the pointer to the list must be set to
NULL.
*/