Libft
42 Libft library documentation
Loading...
Searching...
No Matches
ft_lstclear.c File Reference
+ Include dependency graph for ft_lstclear.c:

Go to the source code of this file.

Functions

void ft_lstclear (t_list **lst, void(*del)(void *))
 Clears a linked list. This function takes a pointer to the first element of a linked list and a function pointer to a deletion function, then removes and frees all elements in the list.
 

Function Documentation

◆ ft_lstclear()

void ft_lstclear ( t_list **  lst,
void(*)(void *)  del 
)

Clears a linked list. This function takes a pointer to the first element of a linked list and a function pointer to a deletion function, then removes and frees all elements in the list.

Parameters
lstA pointer to the pointer to the first element of the list.
delA function pointer to the deletion function.

Definition at line 25 of file ft_lstclear.c.

26{
27 t_list *tmp;
28
29 if (!lst || !del)
30 return ;
31 while (*lst)
32 {
33 tmp = (*lst)->next;
34 ft_lstdelone(*lst, del);
35 *lst = tmp;
36 }
37}
void ft_lstdelone(t_list *lst, void(*del)(void *))
Deletes and frees a single element from a linked list. This function takes an element from a linked l...
Definition types.h:4
struct s_list * next
Definition types.h:6

References ft_lstdelone(), and s_list::next.

Referenced by ft_lstmap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: