libft
src
ft_lstappend.c
Go to the documentation of this file.
1
/* ************************************************************************** */
3
/* */
4
/* ::: :::::::: */
5
/* ft_lstappend.c :+: :+: :+: */
6
/* +:+ +:+ +:+ */
7
/* By: unite <marvin@42.fr> +#+ +:+ +#+ */
8
/* +#+#+#+#+#+ +#+ */
9
/* Created: 2019/09/20 21:44:32 by unite #+# #+# */
10
/* Updated: 2020/07/16 03:03:37 by unite ### ########.fr */
11
/* */
12
/* ************************************************************************** */
13
14
#include "
libft.h
"
15
22
void
ft_lstappend
(
t_list
**alst,
t_list
*
new
)
23
{
24
t_list
*last;
25
26
if
(!alst || !
new
)
27
return ;
28
if
(!*alst)
29
{
30
*alst =
new
;
31
return ;
32
}
33
last =
ft_lstlast
(*alst);
34
last->
next
=
new
;
35
}
s_list
A link in a multi-purpose linked list.
Definition:
libft.h:34
ft_lstlast
t_list * ft_lstlast(t_list *lst)
Returns the last element of a list.
Definition:
ft_lstlast.c:22
s_list::next
struct s_list * next
The next link’s address or NULL if it’s the last link.
Definition:
libft.h:38
libft.h
ft_lstappend
void ft_lstappend(t_list **alst, t_list *new)
Adds the element new at the end of the list.
Definition:
ft_lstappend.c:22
Generated by
1.8.16