-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathft_lstnew.c
38 lines (35 loc) · 1.31 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: vbrazas <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/10 16:26:43 by vbrazas #+# #+# */
/* Updated: 2017/12/06 12:32:43 by vbrazas ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *t;
if (!(t = (t_list *)malloc(sizeof(t_list))))
return (NULL);
if (content == NULL)
{
t->content = NULL;
t->content_size = 0;
}
else
{
if (!(t->content = (void *)malloc(content_size)))
{
free(t);
return (NULL);
}
ft_memcpy(t->content, content, content_size);
t->content_size = content_size;
}
t->next = NULL;
return (t);
}