-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstnew.c
39 lines (36 loc) · 1.41 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: tyassine <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2015/12/01 21:54:48 by tyassine #+# #+# */
/* Updated: 2015/12/08 00:22:19 by tyassine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *newlist;
int i;
newlist = (t_list *)malloc(sizeof(t_list));
if (newlist == NULL)
return (NULL);
if (content == NULL)
{
newlist->content = NULL;
newlist->content_size = 0;
}
else
{
newlist->content = malloc(sizeof(content + 1));
if (newlist->content == NULL)
return (NULL);
newlist->content_size = content_size;
i = -1;
while (++i < (int)content_size)
((char *)(newlist->content))[i] = ((char *)content)[i];
}
return (newlist);
}