-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathft_lstnew.c
executable file
·56 lines (51 loc) · 1.55 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mframbou <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/08/07 21:53:23 by mframbou #+# #+# */
/* Updated: 2021/08/08 22:04:18 by mframbou ### ########.fr */
/* */
/* ************************************************************************** */
#include <stdlib.h>
#include "libft.h"
t_list *ft_lstnew(void const *content)
{
t_list *link;
link = (t_list *) malloc(sizeof (t_list));
if (link)
{
link->content = (void *) content;
link->next = NULL;
}
return (link);
}
/*
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *link;
link = (t_list *) malloc(sizeof (t_list));
if (!link)
return (NULL);
if (content)
{
link->content = malloc(content_size);
if (!link->content)
{
free(link);
return (NULL);
}
ft_memcpy(link->content, content, content_size);
}
else
{
link->content = NULL;
content_size = 0;
}
link->content_size = content_size;
link->next = NULL;
return (link);
}
*/