새로운 t_list 구조체를 생성하고 content를 전달한 뒤 저장하고 반환해주는 함수
t_list *ft_lstnew(void *content)
🔩 parameters
*contest : 생성한 t_list에 저장할 정보
📬 return
t_list *형 반환
- 새로운 t_list 구조체를 생성하고 content를 전달한 뒤 저장하고 반환
- t_list는 libft헤더에 정의했으며 *content에는 필요한 데이터, *next는 현재 노드의 다음 노드주소가 들어간다
typedef struct s_list { void *content; struct s_list *next; } t_list;
#include "libft.h"
t_list *ft_lstnew(void *content)
{
t_list *nlist;
nlist = (t_list *)malloc(sizeof(t_list));
if (nlist == 0)
return (NULL);
nlist->content = content;
nlist->next = NULL;
return (nlist);
}