libft/ft_lst2new.c
2018-09-30 17:54:43 +02:00

41 lines
1.4 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lst2new.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/09/30 17:28:23 by tmaze #+# #+# */
/* Updated: 2018/09/30 17:54:12 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list2 *ft_lst2new(void const *content, size_t content_size)
{
t_list2 *ret;
if ((ret = (t_list2*)malloc(sizeof(t_list2))) != NULL)
{
if (!content)
{
ret->content = NULL;
ret->content_size = 0;
}
else
{
if ((ret->content = malloc(content_size)) == NULL)
{
free(ret);
return (0);
}
ft_memmove(ret->content, content, content_size);
ret->content_size = content_size;
}
ret->next = NULL;
ret->prev = NULL;
}
return (ret);
}