-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathft_lstnew.c
More file actions
39 lines (36 loc) · 1.37 KB
/
ft_lstnew.c
File metadata and controls
39 lines (36 loc) · 1.37 KB
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: atilegen <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/03/25 20:07:58 by atilegen #+# #+# */
/* Updated: 2018/03/25 22:48:25 by atilegen ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *elem;
elem = (t_list *)malloc(sizeof(elem) * content_size);
if (!elem)
return (0);
if (!content)
{
elem->content = NULL;
elem->content_size = 0;
}
else
{
elem->content = malloc(sizeof(content));
if (!elem->content)
return (NULL);
ft_memmove(elem->content, content, content_size);
elem->content_size = content_size;
elem->next = NULL;
return (elem);
}
elem->next = NULL;
return (elem);
}