-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstnew.c
35 lines (32 loc) · 1.29 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: dskrypny <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/18 20:00:20 by dskrypny #+# #+# */
/* Updated: 2017/12/04 19:13:25 by dskrypny ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *elem;
if (!(elem = malloc(sizeof(*elem))))
return (NULL);
if (content != NULL)
{
if (!(elem->content = malloc(content_size)))
return (NULL);
ft_memcpy(elem->content, content, content_size);
elem->content_size = content_size;
}
else
{
elem->content = NULL;
elem->content_size = 0;
}
elem->next = NULL;
return (elem);
}