-
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.47 KB
/
ft_lstclear.c
File metadata and controls
39 lines (36 loc) · 1.47 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: ccarnot <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/05/15 09:35:17 by ccarnot #+# #+# */
/* Updated: 2023/05/15 13:58:08 by ccarnot ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*******************************************
* Function: ft_lstclear
* 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
* Memory allocations: None
* Crash values: None
* Return value: None
*******************************************/
void ft_lstclear(t_list **lst, void (*del)(void*))
{
t_list *ptr;
t_list *tmp;
if (lst && del)
{
ptr = *lst;
while (ptr)
{
tmp = ptr->next;
(*del)(ptr->content);
free(ptr);
ptr = tmp;
}
*lst = 0x0;
}
}