/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* ft_lstnew.c :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: gbrochar +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2015/11/30 21:21:09 by gbrochar #+# #+# */ /* Updated: 2015/12/05 15:10:20 by gbrochar ### ########.fr */ /* */ /* ************************************************************************** */ #include "libft.h" t_list *ft_lstnew(void const *content, size_t content_size) { t_list *lst; lst = (t_list *)malloc(sizeof(t_list)); if (!lst) return (NULL); if (!content) { lst->content = NULL; lst->content_size = 0; } else { lst->content = ft_memalloc(content_size); if (!lst->content) { free(lst); return (NULL); } ft_memmove(lst->content, content, content_size); lst->content_size = content_size; } lst->next = NULL; return (lst); }