-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstlast.c
52 lines (44 loc) · 1.5 KB
/
ft_lstlast.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstlast.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lgasc <lgasc@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/02/14 15:52:21 by lgasc #+# #+# */
/* Updated: 2024/02/27 11:17:28 by lgasc ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
///@return A pointer to the last node of a list, if any
///@param list The beginning of the list.
t_node *ft_lstlast(const t_list list)
{
t_node *node;
if (list == NULL)
return (NULL);
node = list;
while (node->next != NULL)
node = node->next;
return (node);
}
t_ilist ft_ilstlast(const t_ilist list)
{
t_inode *node;
if (list == NULL)
return (NULL);
node = list;
while (node->next != NULL)
node = node->next;
return (node);
}
t_zlist ft_zlstlast(const t_zlist list)
{
t_znode *node;
if (list == NULL)
return (NULL);
node = list;
while (node->next != NULL)
node = node->next;
return (node);
}