-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstrmelem.c
37 lines (34 loc) · 1.27 KB
/
ft_lstrmelem.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstrmelem.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jraymond <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/06/08 16:54:36 by jraymond #+# #+# */
/* Updated: 2018/06/08 17:14:28 by jraymond ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstrmelem(t_list *begin_list, t_list *elem)
{
t_list *el;
t_list *next;
el = begin_list;
if (!begin_list || !elem)
return (NULL);
if (elem == begin_list)
{
elem = elem->next;
free(begin_list);
return (elem);
}
while (el->next != elem && el)
el = el->next;
if (!el)
return (NULL);
next = elem->next;
free(elem);
el->next = next;
return (begin_list);
}