-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstclear_bonus.c
33 lines (30 loc) · 1.25 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: estettle <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/11 11:47:05 by estettle #+# #+# */
/* Updated: 2024/10/11 11:47:05 by estettle ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/* ft_lstclear()
* clears a list and every item, using the del function to remove the content
* of each item. each item is then free()d.
*/
void ft_lstclear(t_list **lst, void (*del)(void *))
{
t_list *next_item;
if (!lst)
return ;
while (*lst)
{
next_item = (*lst)->next;
ft_lstdelone(*lst, del);
*lst = next_item;
}
free(*lst);
*lst = NULL;
}