-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_lstnew.c
executable file
·38 lines (35 loc) · 1.38 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tseguier <tseguier@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2013/11/27 19:12:00 by tseguier #+# #+# */
/* Updated: 2014/03/27 18:39:06 by jcoignet ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *newelem;
newelem = (t_list *)malloc(sizeof(t_list));
if (!newelem)
return (NULL);
if (!content)
{
newelem->content = NULL;
newelem->content_size = 0;
}
else
{
newelem->content = malloc(content_size);
if (!newelem->content)
return (NULL);
ft_memcpy(newelem->content, content, content_size);
newelem->content_size = content_size;
}
newelem->next = NULL;
return ((t_list *)newelem);
}