-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstpop.c
41 lines (38 loc) · 1.27 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
35
36
37
38
39
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstpop.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bpezeshk <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/19 00:38:22 by bpezeshk #+# #+# */
/* Updated: 2017/01/19 13:05:13 by bpezeshk ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstpop(t_list **alst)
{
t_list *pop;
t_list *tmp;
t_list *strt;
if (!alst)
return (NULL);
if (*alst && (*alst)->next)
{
strt = *alst;
tmp = *alst;
pop = (*alst)->next;
while (pop->next)
{
*alst = (*alst)->next;
tmp = *alst;
pop = (*alst)->next;
}
tmp->next = NULL;
*alst = strt;
return (pop);
}
pop = *alst;
*alst = NULL;
return (pop);
}