libft/list/ft_lstnew.c
Raphael 905ffd4b72
refactor: only the usefull header
- Removing all 'libft.h' mention
- Using the include only on the files needed by
2025-09-01 18:45:33 +02:00

33 lines
1.3 KiB
C

/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: rparodi <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/11/12 11:44:02 by rparodi #+# #+# */
/* Updated: 2025/09/01 16:39:00 by rparodi ### ########.fr */
/* */
/* ************************************************************************** */
#include "list.h"
#include <stdlib.h>
/**
* @brief Allocate a new list with the first element
*
* @param content the element to give on first element
* @return the new list
*/
t_list *ft_lstnew(void *content)
{
t_list *to_return;
to_return = NULL;
to_return = (t_list *)malloc(sizeof(t_list));
if (!to_return)
return (NULL);
to_return->content = content;
to_return->next = NULL;
return (to_return);
}