/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstnew.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: gtertysh +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* 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); }