lstnew
This commit is contained in:
parent
f45eac8b2f
commit
944fbdbef5
1 changed files with 9 additions and 5 deletions
|
|
@ -5,21 +5,25 @@ t_list *ft_lstnew(void const *content, size_t content_size)
|
|||
t_list *link;
|
||||
size_t i;
|
||||
|
||||
link->next = NULL;
|
||||
if (!content)
|
||||
{
|
||||
link = malloc(1);
|
||||
if (!link)
|
||||
return (NULL);
|
||||
link->next = NULL;
|
||||
link->content_size = 0;
|
||||
link->content = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
link->content_size = content_size;
|
||||
link->content = ft_memalloc(content_size);
|
||||
if (!link->content)
|
||||
link = ft_memalloc(sizeof(t_list) + content_size);
|
||||
if (!link)
|
||||
return (NULL);
|
||||
link->content_size = content_size;
|
||||
link->next = NULL;
|
||||
i = -1;
|
||||
while (++i < content_size)
|
||||
((char *)link->content)[i] = ((char *)content)[i];
|
||||
}
|
||||
return (link)
|
||||
return (link);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue