-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstdelif.c
41 lines (38 loc) · 1.33 KB
/
ft_lstdelif.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
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstdelif.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mleonett <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/05 17:13:08 by mleonett #+# #+# */
/* Updated: 2018/04/05 17:20:49 by mleonett ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstdelif(t_list **begin_list, void *data_ref, int (*cmp)())
{
t_list *previous;
t_list *next;
t_list *current;
current = *begin_list;
previous = NULL;
while (current)
{
next = current->next;
if (cmp(current->content, data_ref) == 0)
{
free(current);
current = next;
if (previous)
previous->next = current;
else
*begin_list = current;
}
else
{
previous = current;
current = current->next;
}
}
}