-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexec_free2.c
More file actions
67 lines (60 loc) · 1.56 KB
/
exec_free2.c
File metadata and controls
67 lines (60 loc) · 1.56 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* exec_free2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: adurusoy <adurusoy@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/12/20 22:13:27 by adurusoy #+# #+# */
/* Updated: 2023/12/21 08:40:40 by adurusoy ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
#include <stdlib.h>
void free_parse_text(char **text)
{
int i;
i = 0;
if (text)
{
if (text[i])
{
while (text[i])
free(text[i++]);
}
free(text);
}
}
void free_parser(t_shell *m_shell)
{
t_parse *parse;
t_parse *tmp;
parse = m_shell->parse;
if (parse)
{
while (parse)
{
tmp = parse;
parse = parse->next;
if (tmp->cmd)
free(tmp->cmd);
if (tmp->text)
free_parse_text(tmp->text);
free(tmp);
}
}
else if (m_shell->parse)
free(m_shell->parse);
}
int *create_pipe(void)
{
int index;
int *fd;
fd = (int *)malloc(sizeof(int) * 6);
if (!fd)
return (NULL);
index = -1;
while (++index < 6)
fd[index] = 0;
return (fd);
}