-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstnew.c
41 lines (38 loc) · 1.46 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
40
41
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ashongwe <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/05/30 12:16:28 by ashongwe #+# #+# */
/* Updated: 2019/06/13 16:45:40 by ashongwe ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *newlink;
newlink = (t_list*)malloc(sizeof(t_list));
if (newlink == NULL)
return (NULL);
newlink->next = NULL;
if (content == NULL)
{
newlink->content = NULL;
newlink->content_size = 0;
return (newlink);
}
else
{
newlink->content = (t_list*)malloc(sizeof(t_list) * content_size);
if (newlink->content == NULL)
{
free(NULL);
return (NULL);
}
newlink->content = ft_memcpy(newlink->content, content, content_size);
newlink->content_size = content_size;
return (newlink);
}
}