-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstclear.c
More file actions
39 lines (36 loc) · 1.43 KB
/
ft_lstclear.c
File metadata and controls
39 lines (36 loc) · 1.43 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
36
37
38
39
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jowagner <jowagner@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/04 18:26:42 by jowagner #+# #+# */
/* Updated: 2024/12/18 22:24:51 by jowagner ### ########.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 of
* the node.
* @return Nothing.
*/
void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *tmp;
if (!lst || !del)
return ;
while (*lst)
{
tmp = (*lst)->next;
del((*lst)->content);
free(*lst);
*lst = tmp;
}
*lst = NULL;
}