-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlist_foncs.c
More file actions
71 lines (63 loc) · 1.62 KB
/
list_foncs.c
File metadata and controls
71 lines (63 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* list_foncs.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bguzel <bguzel@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/09/09 16:36:56 by bguzel #+# #+# */
/* Updated: 2023/09/09 18:16:33 by bguzel ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void link_lstclear(t_list **lst)
{
t_list *tmp;
if (!lst)
{
return ;
}
while (*lst != NULL)
{
tmp = (*lst)->next;
link_lstdelone(*lst);
*lst = tmp;
}
}
void link_lstdelone(t_list *lst)
{
if (!lst)
return ;
free(lst->content);
free(lst);
}
void link_lstadd_back(t_list **lst, t_list *new)
{
if (*lst == NULL)
{
*lst = new;
return ;
}
link_lstlast(*lst)->next = new;
}
t_list *link_lstlast(t_list *lst)
{
if (lst == NULL)
return (NULL);
while (lst->next != NULL)
{
lst = lst->next;
}
return (lst);
}
t_list *link_lstnew(char *content, char flag)
{
t_list *str;
str = malloc(sizeof(t_list));
if (!str)
return (0);
str->content = content;
str->flag = flag;
str->next = NULL;
return (str);
}