-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstclear_bonus.c
35 lines (31 loc) · 1.35 KB
/
ft_lstclear_bonus.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bnidia <bnidia@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/10/17 14:43:19 by bnidia #+# #+# */
/* Updated: 2021/10/25 19:44:44 by bnidia ### ########.fr */
/* */
/* ************************************************************************** */
/* ft_lstclear
** 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
**
*/
#include "libft.h"
void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *present_elem;
t_list *next_elem;
present_elem = *lst;
while (present_elem != NULL)
{
next_elem = present_elem->next;
ft_lstdelone(present_elem, del);
present_elem = next_elem;
}
*lst = NULL;
}