-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstnew.c
35 lines (32 loc) · 1.33 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: malexand <malexand@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/06/25 17:01:45 by root #+# #+# */
/* Updated: 2017/02/16 17:34:22 by malexand ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(const void *content, size_t content_size)
{
t_list *list;
void *new_content;
if (!(new_content = ft_memalloc(content_size)))
return (NULL);
if (!content)
{
new_content = NULL;
content_size = 0;
}
else
ft_memcpy(new_content, content, content_size);
if (!(list = (t_list*)malloc(sizeof(t_list))))
return (NULL);
list->content = new_content;
list->content_size = content_size;
list->next = NULL;
return (list);
}