-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstpop.c
34 lines (31 loc) · 1.18 KB
/
ft_lstpop.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstpop.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ylagtab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/09 00:13:53 by ylagtab #+# #+# */
/* Updated: 2019/04/10 18:16:45 by ylagtab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstpop(t_list **alst)
{
t_list *node;
t_list *tmp;
if (*alst == NULL)
return (NULL);
if ((*alst)->next == NULL)
{
node = *alst;
*alst = NULL;
return (node);
}
tmp = *alst;
while (tmp->next->next)
tmp = tmp->next;
node = tmp->next;
tmp->next = NULL;
return (node);
}