-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstnew.c
36 lines (33 loc) · 1.35 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ylagtab <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/04/05 13:45:40 by ylagtab #+# #+# */
/* Updated: 2021/01/15 19:12:07 by ylagtab ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *node;
if ((node = (t_list *)ft_malloc(sizeof(t_list))) == NULL)
return (NULL);
node->next = NULL;
if (content == NULL)
{
node->content = NULL;
node->content_size = 0;
return (node);
}
if ((node->content = ft_memalloc(content_size)) == NULL)
{
free(node);
return (NULL);
}
node->content_size = content_size;
ft_memcpy(node->content, content, content_size);
return (node);
}