-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstadd_front.c
74 lines (59 loc) · 1.62 KB
/
ft_lstadd_front.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstadd_front.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: musenov <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/25 11:52:39 by musenov #+# #+# */
/* Updated: 2022/12/06 02:49:36 by musenov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
void ft_lstadd_front(t_list **lst, t_list *new)
{
if (lst)
{
if (*lst)
(*new).next = *lst;
*lst = new;
}
}
/*
ft_lstadd_front:
PARAMETERS
lst: The address of a pointer to the first link of a list.
new: The address of a pointer to the node to be added to the list.
RETURN VALUE
None
DESCRIPTION
Adds the node ’new’ at the beginning of the list.
QUESTIONS
-/-
ANSWER
-/-
COMPARE
void ft_lstadd_back(t_list **lst, t_list *new)
{
t_list *lst_back;
if (new == NULL)
return ;
if (*lst == NULL)
{
*lst = new;
return ;
}
lst_back = ft_lstlast(*lst);
(*lst_back).next = new;
}
ALTERNATIVE SOLUTION
void ft_lstadd_front(t_list **lst, t_list *new)
{
(*new).next = *lst;
*lst = new;
}
EXPLANATION
-/-
REMARK
-/-
*/