ft_lstnew
Subject
FT_LSTNEW (simplified)
NAME
ft_lstnew -- create a new list node element
SYNOPSIS
t_list *ft_lstnew(void *content);
DESCRIPTION
Allocate (with malloc(3)) and return the new element. The member variable 'content' is initialized with the value of the 'content' parameter. The 'next' variable is initialized to NULL.
PARAMETERS
content: The content of the new element
RETURN VALUES
The new element.
AUTHORIZED EXTERNAL FUNCTIONS
malloc(3)
Understandable explanation
This function allocates memory for a new element of type t_list
, setting its content
to be the content
parameter, and setting the next
variable to NULL
.
Then it returns the newly allocated / created element of the list.
Hints
/* declare a new list element */
/* allocate memory for it */
/* set the new element variables
* new->content = content
* new->next = NULL
*/
/* return the new element */
Commented solution
Last updated
Was this helpful?