-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstnew.c
36 lines (33 loc) · 1.32 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: mtan <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/02/21 22:12:51 by mtan #+# #+# */
/* Updated: 2018/02/21 22:12:52 by mtan ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *res;
if ((res = (t_list *)malloc(sizeof(t_list))))
{
if (!content)
{
res->content = NULL;
res->content_size = 0;
}
else
{
if (!(res->content = ft_memalloc(content_size)))
return (NULL);
res->content = ft_memcpy(res->content, content, content_size);
res->content_size = content ? content_size : 0;
}
res->next = NULL;
}
return (res);
}