-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstclear_bonus.c
More file actions
35 lines (33 loc) · 1.4 KB
/
ft_lstclear_bonus.c
File metadata and controls
35 lines (33 loc) · 1.4 KB
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_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tcharuel <tcharuel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/08 13:48:52 by tcharuel #+# #+# */
/* Updated: 2023/11/08 15:25:22 by tcharuel ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/**
* @brief 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.
*
* @param lst: The address of a pointer to a node.
* @param del: The address of the function used to delete
* the content.
*/
void ft_lstclear(t_list **lst, void (*del)(void*))
{
if (!lst || !*lst || !del)
return ;
if ((*lst)->next)
ft_lstclear(&(*lst)->next, del);
(*del)((*lst)->content);
free(*lst);
*lst = NULL;
}