-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmin_free.c
executable file
·69 lines (62 loc) · 1.54 KB
/
min_free.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* min_free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: potero-d <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/03/21 09:51:07 by potero-d #+# #+# */
/* Updated: 2022/07/14 13:39:17 by potero-d ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void free_arg_str(char *str, t_argv *argv)
{
t_argv *aux;
int i;
aux = argv;
while (argv)
{
i = 0;
while (argv->split[i])
{
free(argv->split[i]);
i++;
}
free(argv->split);
free(argv->arg);
free(argv->direction);
free(argv->infile);
free(argv->outfile);
aux = argv->next;
free(argv);
argv = aux;
}
free(argv);
free(str);
}
void free_env(t_myenv *myenv)
{
t_myenv *aux;
aux = myenv;
while (myenv)
{
aux = myenv->next;
free(myenv->key);
free(myenv->value);
free(myenv);
myenv = aux;
}
free(myenv);
}
void free_env_char(char **str)
{
int i;
i = 0;
while (str[i])
{
free(str[i]);
i++;
}
free(str);
}