ft_nm/subprojects/libft/ft_lstnew.c
2019-05-10 18:29:21 +03:00

40 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: gtertysh <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2016/12/04 15:59:21 by gtertysh #+# #+# */
/* Updated: 2016/12/06 19:45:44 by gtertysh ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *new;
new = NULL;
if ((new = (t_list *)malloc(sizeof(t_list))))
{
if (!content)
{
new->content = NULL;
new->content_size = 0;
}
else
{
if (!(new->content = (char *)malloc(content_size)))
{
free(new);
return (NULL);
}
ft_memcpy(new->content, content, content_size);
new->content_size = content_size;
}
new->next = NULL;
}
return (new);
}