data_structures
src
data_structures
list
list_unlink_first.c
Go to the documentation of this file.
1
/* ************************************************************************** */
3
/* */
4
/* ::: :::::::: */
5
/* list_remove_first.c :+: :+: :+: */
6
/* +:+ +:+ +:+ */
7
/* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8
/* +#+#+#+#+#+ +#+ */
9
/* Created: 2020/07/18 16:00:12 by unite #+# #+# */
10
/* Updated: 2020/07/21 22:32:35 by unite ### ########.fr */
11
/* */
12
/* ************************************************************************** */
13
14
#include "
list.h
"
15
16
void
*
list_unlink_first
(
t_list
*alst)
17
{
18
t_link
*tmp;
19
void
*content;
20
21
if
(alst->
size
== 0)
22
return
(NULL);
23
content = alst->
head
->
content
;
24
tmp = alst->
head
;
25
alst->
head
= alst->
head
->
next
;
26
free(tmp);
27
alst->
size
--;
28
if
(alst->
size
== 0)
29
alst->
tail
= NULL;
30
else
31
alst->
head
->
prev
= NULL;
32
return
(content);
33
}
s_link::content
void * content
The content.
Definition:
list.h:36
s_list::head
t_link * head
The first link.
Definition:
list.h:56
s_list
Doubly-linked list of generic items.
Definition:
list.h:54
s_list::tail
t_link * tail
The last link.
Definition:
list.h:57
s_list::size
size_t size
The number of items in the list.
Definition:
list.h:58
s_link::prev
struct s_link * prev
The previous link.
Definition:
list.h:38
list_unlink_first
void * list_unlink_first(t_list *alst)
Removes the first item in the list and returns it.
Definition:
list_unlink_first.c:16
s_link::next
struct s_link * next
The next link.
Definition:
list.h:37
list.h
s_link
A link in a doubly-linked list.
Definition:
list.h:34
Generated by
1.8.16