-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_ldcdpop.c
executable file
·33 lines (30 loc) · 1.3 KB
/
ft_ldcdpop.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_ldcdpop.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tseguier <tseguier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/01/10 02:49:06 by tseguier #+# #+# */
/* Updated: 2014/03/27 18:38:38 by jcoignet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
#include "ft_ldcd_cell.h"
void *ft_ldcdpop(t_ldcd ldcd, t_ldcd_cell cell)
{
void *elem;
if (!ldcd || !cell)
return (NULL);
if (cell->prev == NULL)
return (ft_ldcdpop_front(ldcd));
if (cell->next == NULL)
return (ft_ldcdpop_back(ldcd));
elem = cell->content;
cell->prev->next = cell->next;
cell->next->prev = cell->prev;
ft_ldcd_celldel(&cell, NULL);
--(ldcd->size);
return (elem);
}