-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_dlstclear.c
36 lines (32 loc) · 1.25 KB
/
ft_dlstclear.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
36
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_dlstclear.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lrocigno <lrocigno@student.42sp.org.br> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/08 23:20:56 by lrocigno #+# #+# */
/* Updated: 2022/01/16 12:18:01 by lrocigno ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
/*
** Clear a double linked list.
*/
void ft_dlstclear(t_dlist **dlst_del, void (*del)(void *))
{
t_dlist *holder;
if (!*dlst_del)
return ;
while ((*dlst_del)->prev)
*dlst_del = (*dlst_del)->prev;
holder = *dlst_del;
while (*dlst_del)
{
holder = (*dlst_del)->next;
del((*dlst_del)->content);
free(*dlst_del);
*dlst_del = holder;
}
*dlst_del = NULL;
}