41 lines
1.3 KiB
C
41 lines
1.3 KiB
C
|
/* ************************************************************************** */
|
||
|
/* */
|
||
|
/* ::: :::::::: */
|
||
|
/* ft_lstnew.c :+: :+: :+: */
|
||
|
/* +:+ +:+ +:+ */
|
||
|
/* By: gbrochar <marvin@42.fr> +#+ +:+ +#+ */
|
||
|
/* +#+#+#+#+#+ +#+ */
|
||
|
/* Created: 2015/11/30 21:21:09 by gbrochar #+# #+# */
|
||
|
/* Updated: 2016/02/27 21:04:51 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);
|
||
|
}
|