/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstnew.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: hulamy +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2018/11/14 21:11:42 by hulamy #+# #+# */ /* Updated: 2018/11/16 14:01:36 by hulamy ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" t_list *ft_lstnew(void const *content, size_t content_size) { t_list *lst; if (!(lst = (t_list *)malloc(sizeof(*lst)))) return (NULL); if (!content) { lst->content = NULL; lst->content_size = 0; } else { if (!(lst->content = malloc(content_size))) return (NULL); ft_memcpy(lst->content, content, content_size); lst->content_size = content_size; } lst->next = NULL; return (lst); }