Repository navigation
Expand file tree
/
Copy pathfree.c
More file actions
56 lines (51 loc) · 1.53 KB
/
Copy pathfree.c
File metadata and controls
56 lines (51 loc) · 1.53 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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lwang <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/05/05 10:08:48 by lwang #+# #+# */
/* Updated: 2017/05/05 10:08:50 by lwang ### ########.fr */
/* */
/* ************************************************************************** */
#include "minishell.h"
void deep_free(char **dst)
{
int i;
i = 0;
if (dst)
while (dst[i])
{
free(dst[i]);
i++;
}
free(dst);
dst = NULL;
}
void free_for_loop(t_minfo *info)
{
deep_free(info->cmd_env);
info->cmd_env = NULL;
deep_free(info->av);
info->av = NULL;
free(info->cmd);
info->cmd = NULL;
free(info->cmd_path);
info->cmd_path = NULL;
free(info->line);
info->line = NULL;
}
void free_everything(t_minfo *info)
{
deep_free(info->env);
deep_free(info->cmd_env);
free(info->home);
free(info->env_path);
deep_free(info->pre_path);
deep_free(info->av);
free(info->cmd);
free(info->cmd_path);
free(info->line);
get_next_line(-42, NULL);
}