37 lines
1.4 KiB
C
37 lines
1.4 KiB
C
/* ************************************************************************** */
|
|
/* */
|
|
/* ::: :::::::: */
|
|
/* ft_lstnew.c :+: :+: :+: */
|
|
/* +:+ +:+ +:+ */
|
|
/* By: jfleury <marvin@42.fr> +#+ +:+ +#+ */
|
|
/* +#+#+#+#+#+ +#+ */
|
|
/* Created: 2019/03/12 13:54:39 by jfleury #+# #+# */
|
|
/* Updated: 2019/04/23 14:13:31 by allefebv ### ########.fr */
|
|
/* */
|
|
/* ************************************************************************** */
|
|
|
|
#include <stdlib.h>
|
|
#include "libft.h"
|
|
|
|
t_list *ft_lstnew(void const *content, size_t content_size)
|
|
{
|
|
t_list *newlst;
|
|
|
|
if (!(newlst = (t_list*)malloc(sizeof(t_list))))
|
|
return (NULL);
|
|
if (content == NULL)
|
|
{
|
|
newlst->content = NULL;
|
|
newlst->content_size = 0;
|
|
}
|
|
else
|
|
{
|
|
if (!(newlst->content = (void*)malloc(sizeof(content) * content_size)))
|
|
return (NULL);
|
|
ft_memcpy((newlst->content), content, content_size);
|
|
newlst->content_size = content_size;
|
|
}
|
|
newlst->next = NULL;
|
|
return (newlst);
|
|
}
|