-
Notifications
You must be signed in to change notification settings - Fork 0
/
v_free_cmd_red_env.c
59 lines (54 loc) · 1.56 KB
/
v_free_cmd_red_env.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* v_free_cmd_red_env.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: jkassand <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/11/27 01:30:59 by jkassand #+# #+# */
/* Updated: 2021/11/27 01:31:02 by jkassand ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
static void free_red_cmd(t_arg *arg)
{
t_red *red;
t_cmd *cmd;
int i;
while (arg->red)
{
red = arg->red;
arg->red = arg->red->next;
if (red->in && red->two)
unlink(red->name);
free(red->name);
free(red->limiter);
free(red);
}
while (arg->cmd)
{
cmd = arg->cmd;
arg->cmd = arg->cmd->next;
i = -1;
while (cmd->cmd[++i])
free(cmd->cmd[i]);
free(cmd->cmd);
free(cmd);
}
}
void free_str(t_arg *arg, char *str)
{
int i;
free(str);
free_red_cmd(arg);
i = 0;
while (arg->fd && arg->fd[i])
free(arg->fd[i++]);
free(arg->fd);
arg->fd = NULL;
i = 0;
while (arg->env && arg->env[i])
free(arg->env[i++]);
free(arg->env);
arg->env = NULL;
}