minishell
ft_lst.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  t_list
 

Functions

t_listft_lstnew (void *content)
 
void ft_lstadd_front (t_list **lst, t_list *new)
 
int ft_lstsize (t_list *lst)
 
t_listft_lstlast (t_list *lst)
 
void ft_lstadd_back (t_list **lst, t_list *new)
 
void ft_lstdelone (t_list *lst, void(*del)(void *))
 
void ft_lstclear (t_list **lst, void(*del)(void *))
 
void ft_lstiter (t_list *lst, void(*f)(void *))
 
t_listft_lstmap (t_list *lst, void *(*f)(void *), void(*del)(void *))
 

Function Documentation

◆ ft_lstadd_back()

void ft_lstadd_back ( t_list **  lst,
t_list new 
)

Definition at line 16 of file ft_lstadd_back.c.

17 {
18  if (lst == NULL || new == NULL)
19  return ;
20  if (*lst == NULL)
21  *lst = new;
22  else
23  ft_lstlast(*lst)->next = new;
24 }
t_list * ft_lstlast(t_list *lst)
Definition: ft_lstlast.c:16
struct s_list * next
Definition: ft_lst.h:20
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ft_lstadd_front()

void ft_lstadd_front ( t_list **  lst,
t_list new 
)

Definition at line 16 of file ft_lstadd_front.c.

17 {
18  if (lst == NULL || new == NULL)
19  return ;
20  new->next = *lst;
21  *lst = new;
22 }

◆ ft_lstclear()

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

Definition at line 16 of file ft_lstclear.c.

17 {
18  t_list *p_next;
19 
20  if (lst == NULL || *lst == NULL || del == NULL)
21  return ;
22  while (*lst != NULL)
23  {
24  p_next = (*lst)->next;
25  ft_lstdelone(*lst, del);
26  *lst = p_next;
27  }
28 }
void ft_lstdelone(t_list *lst, void(*del)(void *))
Definition: ft_lstdelone.c:16
Definition: ft_lst.h:18
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ft_lstdelone()

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

Definition at line 16 of file ft_lstdelone.c.

17 {
18  if (lst == NULL || del == NULL)
19  return ;
20  del(lst->content);
21  free(lst);
22 }
void * content
Definition: ft_lst.h:19
Here is the caller graph for this function:

◆ ft_lstiter()

void ft_lstiter ( t_list lst,
void(*)(void *)  f 
)

Definition at line 16 of file ft_lstiter.c.

17 {
18  if (lst == NULL || f == NULL)
19  return ;
20  while (lst != NULL)
21  {
22  f(lst->content);
23  lst = lst->next;
24  }
25 }

◆ ft_lstlast()

t_list* ft_lstlast ( t_list lst)

Definition at line 16 of file ft_lstlast.c.

17 {
18  if (lst != NULL)
19  while (lst->next != NULL)
20  lst = lst->next;
21  return (lst);
22 }
Here is the caller graph for this function:

◆ ft_lstmap()

t_list* ft_lstmap ( t_list lst,
void *(*)(void *)  f,
void(*)(void *)  del 
)

Definition at line 16 of file ft_lstmap.c.

17 {
18  t_list *p_new_lst_top;
19  t_list *p_new_lst;
20 
21  if (lst == NULL)
22  return (NULL);
23  p_new_lst_top = ft_lstnew(f(lst->content));
24  if (p_new_lst_top == NULL)
25  return (NULL);
26  p_new_lst = p_new_lst_top;
27  lst = lst->next;
28  while (lst != NULL)
29  {
30  p_new_lst->next = ft_lstnew(f(lst->content));
31  p_new_lst = p_new_lst->next;
32  lst = lst->next;
33  if (p_new_lst == NULL)
34  {
35  ft_lstclear(&p_new_lst_top, del);
36  return (NULL);
37  }
38  }
39  return (p_new_lst_top);
40 }
void ft_lstclear(t_list **lst, void(*del)(void *))
Definition: ft_lstclear.c:16
t_list * ft_lstnew(void *content)
Definition: ft_lstnew.c:16
Here is the call graph for this function:

◆ ft_lstnew()

t_list* ft_lstnew ( void *  content)

Definition at line 16 of file ft_lstnew.c.

17 {
18  t_list *p_ret;
19 
20  p_ret = malloc(sizeof(t_list));
21  if (p_ret != NULL)
22  {
23  p_ret->content = content;
24  p_ret->next = NULL;
25  }
26  return (p_ret);
27 }
Here is the caller graph for this function:

◆ ft_lstsize()

int ft_lstsize ( t_list lst)

Definition at line 16 of file ft_lstsize.c.

17 {
18  size_t count;
19 
20  if (lst == NULL)
21  return (0);
22  count = 0;
23  while (lst != NULL)
24  {
25  count++;
26  lst = lst->next;
27  }
28  return (count);
29 }