-
Notifications
You must be signed in to change notification settings - Fork 0
/
freedom_sings.c
executable file
·74 lines (66 loc) · 937 Bytes
/
freedom_sings.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
74
#include "minishell.h"
void free_split(char **splited)
{
int pos;
pos = 0;
while (splited[pos])
{
free(splited[pos]);
pos++;
}
free(splited);
}
void free_stack(t_list **stack)
{
t_list *temp;
while (*stack)
{
temp = *stack;
*stack = (*stack)->next;
free(temp);
}
*stack = NULL;
temp = NULL;
}
void ft_freenode(t_list *cmd)
{
t_list *temp;
t_list *aux;
int i;
temp = cmd;
while (temp)
{
aux = temp;
i = -1;
if (aux->cmd_path)
free(aux->cmd_path);
if (aux->cmd)
{
while (aux->cmd[++i])
free(aux->cmd[i]);
free(aux->cmd);
}
if (aux->infile > 2)
close(aux->infile);
if (aux->outfile > 2)
close(aux->outfile);
temp = temp->next;
free(aux);
}
}
void freethree_ptrs(char **s, char **s2, char **s3)
{
free(*s);
free(*s2);
free(*s3);
*s = NULL;
*s2 = NULL;
*s3 = NULL;
}
void freetwo_ptrs(char **s, char **s2)
{
free(*s);
free(*s2);
*s = NULL;
*s2 = NULL;
}