-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_lstnew.c
41 lines (35 loc) · 1.46 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jede-ara <jede-ara@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/11/11 12:59:56 by jede-ara #+# #+# */
/* Updated: 2022/11/11 12:59:59 by jede-ara ### ########.fr */
/* */
/* ************************************************************************** */
/*
DESCRIÇÃO: lstnew() aloca (com malloc(3)) e retorna um novo elemento,
ou seja, cria uma nova lista. A variável content é inicializada com o
valor do parâmetro 'content', a variável 'next' é inicializada como NULL.
*/
#include "libft.h"
t_list *ft_lstnew(void *content)
{
t_list *node;
node = (t_list *) malloc (sizeof(t_list));
if (!node)
return (0);
node->content = content;
node->next = NULL;
return (node);
}
/*#include <stdio.h>
int main()
{
char str[] = "testando a função lstnew";
t_list *tst;
tst = ft_lstnew((void *)str);
printf("\n%s\n", (char *)tst->content);
}*/