-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstnew.c
39 lines (36 loc) · 1.33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lbopp <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/11/12 09:34:11 by lbopp #+# #+# */
/* Updated: 2016/11/12 15:37:44 by lbopp ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *new;
new = NULL;
if (!(new = (t_list*)malloc(sizeof(t_list))))
return (NULL);
if (content == 0)
{
new->content = NULL;
new->content_size = 0;
}
else
{
if (!(new->content = (void*)malloc(content_size)))
{
free(new);
return (NULL);
}
ft_memcpy(new->content, content, content_size);
new->content_size = content_size;
}
new->next = NULL;
return (new);
}