-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfree_1.c
73 lines (64 loc) · 1.82 KB
/
free_1.c
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
72
73
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free_1.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: ngasco <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/14 11:26:32 by ngasco #+# #+# */
/* Updated: 2022/03/14 11:26:35 by ngasco ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
/* Linked list's nodes are deallocated one by one */
void ft_deallocate_quotes_list(struct s_qnode **quotes_list)
{
struct s_qnode *curr;
struct s_qnode *aux;
curr = *quotes_list;
if (curr == NULL)
*quotes_list = NULL;
else
{
aux = curr;
ft_deallocate_quotes_list(&curr->next);
free(aux->str);
free(aux);
}
}
/* Linked list's nodes are deallocated one by one */
void ft_deallocate_tokens_list(struct s_tnode **token_list)
{
struct s_tnode *curr;
curr = *token_list;
if (curr == NULL)
*token_list = NULL;
else
{
ft_deallocate_tokens_list(&curr->next);
free(curr->str);
free(curr);
}
}
void ft_free_export(t_cdata *t_cdata)
{
int i;
i = 0;
while (t_cdata->envp_export[i] != NULL)
{
free(t_cdata->envp_export[i]);
i++;
}
free(t_cdata->envp_export);
}
void ft_free_envp(t_cdata *t_cdata)
{
int i;
i = 0;
while (t_cdata->envp[i] != NULL)
{
free(t_cdata->envp[i]);
i++;
}
free(t_cdata->envp);
}