You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

36 lines
1.2 KiB

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: emartine <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/11/09 17:38:16 by emartine #+# #+# */
/* Updated: 2017/11/09 17:38:19 by emartine ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *r;
if (!(r = (t_list *)malloc(sizeof(*r))))
return (NULL);
if (content == NULL)
{
r->content = NULL;
r->content_size = 0;
}
else
{
if (!(r->content = ft_memdup(content, content_size)))
{
free(r);
return (NULL);
}
r->content_size = content_size;
}
return (r);
}