data_structures
list_unlink_last.c
Go to the documentation of this file.
1 /* ************************************************************************** */
3 /* */
4 /* ::: :::::::: */
5 /* list_remove_last.c :+: :+: :+: */
6 /* +:+ +:+ +:+ */
7 /* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8 /* +#+#+#+#+#+ +#+ */
9 /* Created: 2020/07/18 16:00:19 by unite #+# #+# */
10 /* Updated: 2020/07/21 22:32:36 by unite ### ########.fr */
11 /* */
12 /* ************************************************************************** */
13 
14 #include "list.h"
15 
17 {
18  t_link *tmp;
19  void *content;
20 
21  if (alst->size == 0)
22  return (NULL);
23  content = alst->tail->content;
24  tmp = alst->tail;
25  alst->tail = alst->tail->prev;
26  free(tmp);
27  alst->size--;
28  if (alst->size == 0)
29  alst->head = NULL;
30  else
31  alst->tail->next = NULL;
32  return (content);
33 }
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
list.h