-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathft_lstnew.c
41 lines (38 loc) · 1.4 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: rlambert <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2014/11/07 10:56:43 by rlambert #+# #+# */
/* Updated: 2014/11/07 18:50:27 by rlambert ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *retval;
retval = (t_list*)malloc(sizeof(t_list));
if (retval == NULL)
return (NULL);
if (content == NULL)
{
retval->content = NULL;
retval->content_size = 0;
}
else
{
retval->content = malloc(content_size);
if (content == NULL)
{
free(retval);
return (NULL);
}
ft_memcpy(retval->content, content, content_size);
retval->content_size = content_size;
}
retval->next = NULL;
return (retval);
}