Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_lstnew.c File Reference
#include <stdlib.h>
#include "../includes/types.h"
+ Include dependency graph for ft_lstnew.c:

Go to the source code of this file.

Functions

t_listft_lstnew (void *content)
 Creates a new linked-list node.
 

Function Documentation

◆ ft_lstnew()

t_list * ft_lstnew ( void *  content)

Creates a new linked-list node.

The node is initialized with content and its next pointer is set to NULL.

Parameters
contentPointer stored in the node.
Returns
Newly allocated node, or NULL on allocation failure.

Definition at line 24 of file ft_lstnew.c.

25{
26 t_list *new_elem;
27
28 new_elem = (t_list *)malloc(sizeof(t_list));
29 if (!new_elem)
30 return (NULL);
31 new_elem->content = content;
32 new_elem->next = NULL;
33 return (new_elem);
34}
Definition types.h:4
struct s_list * next
Definition types.h:6
void * content
Definition types.h:5

References s_list::content, and s_list::next.

Referenced by ft_lstmap().

+ Here is the caller graph for this function: