ft_lstnew: initial implementation

This commit is contained in:
Khaïs COLIN 2024-10-21 11:28:06 +02:00
parent 1126640edc
commit 8777bfc3c3
3 changed files with 50 additions and 2 deletions

41
ft_lstnew_bonus.c Normal file
View file

@ -0,0 +1,41 @@
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_lstnew_bonus.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: kcolin <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/10/21 11:19:42 by kcolin #+# #+# */
/* Updated: 2024/10/21 11:25:46 by kcolin ### ########.fr */
/* */
/* ************************************************************************** */
#include "libft.h"
#include <stdlib.h>
t_list *ft_lstnew(void *content)
{
t_list *out;
out = malloc(sizeof(t_list));
if (out == NULL)
return (NULL);
out->content = content;
out->next = NULL;
return (out);
}
/*
#include <stdio.h>
int main(void)
{
t_list *list;
list = ft_lstnew("Hello There!");
printf("content:\t%s\n", (char *)list->content);
printf("next:\t%p\n", list->next);
free(list);
return (0);
}
*/