-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_ldcdpop_front.c
executable file
·34 lines (31 loc) · 1.28 KB
/
ft_ldcdpop_front.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_ldcdpop_front.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tseguier <tseguier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/12/04 02:35:59 by tseguier #+# #+# */
/* Updated: 2014/03/27 18:38:42 by jcoignet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
#include "ft_ldcd_cell.h"
void *ft_ldcdpop_front(t_ldcd ldcd)
{
void *elem;
t_ldcd_cell temp;
if (!ldcd || !ldcd->head)
return (NULL);
elem = ldcd->head->content;
if (!ldcd->head->next)
ldcd->tail = NULL;
else
ldcd->head->next->prev = NULL;
temp = ldcd->head;
ldcd->head = ldcd->head->next;
ft_ldcd_celldel(&temp, NULL);
--(ldcd->size);
return (elem);
}