-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstnew.c
39 lines (36 loc) · 1.39 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: ardurand <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/04 12:19:50 by ardurand #+# #+# */
/* Updated: 2017/01/19 16:17:10 by ardurand ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *list;
void *content_cpy;
content_cpy = NULL;
if (!content)
content_size = 0;
else
{
content_cpy = ft_memalloc(content_size);
if (content_cpy == NULL)
return (NULL);
content_cpy = ft_memcpy(content_cpy, content, content_size);
}
if (!(list = (t_list*)malloc(sizeof(t_list))))
return (NULL);
{
list->content = content_cpy;
list->content_size = content_size;
list->next = NULL;
return (list);
}
return (NULL);
}