-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstnew.c
36 lines (33 loc) · 1.28 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: rnbou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/10/12 04:11:59 by rnbou #+# #+# */
/* Updated: 2018/10/12 10:43:13 by rnbou ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(const void *content, size_t content_size)
{
t_list *l;
if (!(l = malloc(sizeof(t_list))))
return (NULL);
if (!(content))
{
l->content = NULL;
l->content_size = 0;
l->next = NULL;
}
else
{
if (!(l->content = malloc(content_size)))
return (NULL);
ft_memcpy(l->content, content, content_size);
l->content_size = content_size;
l->next = NULL;
}
return (l);
}