-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_atom_lst_delatom.c
32 lines (30 loc) · 1.25 KB
/
ft_atom_lst_delatom.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_atom_lst_delatom.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mle-roy <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/02/11 17:02:02 by mle-roy #+# #+# */
/* Updated: 2015/01/31 22:08:07 by mle-roy ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
void ft_atom_lst_delatom(t_lst *l, t_atom *atom, void (*del)(void *content))
{
if (del != NULL)
del(atom->content);
free(atom->content);
if (atom == l->first)
ft_atom_lst_pop(l);
else if (atom == l->last)
ft_atom_lst_popend(l);
else
{
atom->prev->next = atom->next;
atom->next->prev = atom->prev;
l->len--;
}
free(atom);
}