fuckinlem_in/libft/srcs/ft_lstnew.c
Tanguy MAZE 54be2278c0 It finnaly kinda works
algorithm with no double nodes and nearly efficient enough
still some optimizations to find for --big-superposition maps
2019-04-18 20:18:50 +02:00

40 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: tmaze <tmaze@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2018/04/08 00:35:42 by tmaze #+# #+# */
/* Updated: 2018/04/08 17:15:34 by tmaze ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
t_list *ft_lstnew(void const *content, size_t content_size)
{
t_list *ret;
if ((ret = (t_list*)malloc(sizeof(t_list))) != 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;
}
return (ret);
}