-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstnew.c
73 lines (56 loc) · 1.6 KB
/
ft_lstnew.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: musenov <[email protected] +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/25 11:32:15 by musenov #+# #+# */
/* Updated: 2022/12/07 18:09:04 by musenov ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void *content)
{
t_list *tmp;
tmp = malloc(sizeof(t_list));
if (tmp)
{
(*tmp).content = content;
(*tmp).next = 0;
}
return (tmp);
}
/*
ft_lstnew:
PARAMETERS
content: The content to create the node with.
RETURN VALUE
The new node
DESCRIPTION
Allocates (with malloc(3)) and returns a new node. The member variable
’content’ is initialized with the value of the parameter ’content’.
The variable ’next’ is initialized to NULL.
QUESTIONS
-/-
ANSWER
-/-
COMPARE
-/-
ALTERNATIVE SOLUTION
t_list *ft_lstnew(void *content)
{
t_list *tmp;
tmp = malloc(sizeof(t_list));
if (tmp)
{
(*tmp).content = content;
(*tmp).next = NULL;
}
return (tmp);
}
EXPLANATION
-/-
REMARK
-/-
*/