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