-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_atom_lst_popend.c
36 lines (33 loc) · 1.23 KB
/
ft_atom_lst_popend.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atom_lst_popend.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mle-roy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/02/11 16:33:49 by mle-roy #+# #+# */
/* Updated: 2014/02/11 16:37:02 by mle-roy ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_atom *ft_atom_lst_popend(t_lst *list)
{
t_atom *pop;
if (list->first == NULL || list->last == NULL)
return (NULL);
pop = list->last;
if (pop->prev == NULL)
{
list->first = NULL;
list->last = NULL;
}
else
{
list->last = pop->prev;
list->last->next = NULL;
}
pop->next = NULL;
pop->prev = NULL;
list->len--;
return (pop);
}