-
Notifications
You must be signed in to change notification settings - Fork 0
/
free.c
70 lines (63 loc) · 1.53 KB
/
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
70
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* free.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: mleclair <mleclair@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/01/17 18:14:40 by mleclair #+# #+# */
/* Updated: 2017/03/22 18:01:42 by mleclair ### ########.fr */
/* */
/* ************************************************************************** */
#include "chell.h"
void env_free2(t_env *env)
{
int i;
i = 0;
if (env->savev && (i = -1))
{
while (env->savev[++i])
free(env->savev[i]);
free(env->savev);
}
if (env->path && (i = -1))
{
while (env->path[++i])
free(env->path[i]);
free(env->path);
}
}
void env_free(t_env *env)
{
int i;
i = -1;
if (env)
{
if (env->input)
{
free(env->input);
env->input = NULL;
}
if (env->dir)
free(env->dir);
if (env->ev)
{
while (env->ev[++i])
free(env->ev[i]);
free(env->ev);
}
env_free2(env);
}
}
int free_double_array(char **t)
{
int i;
i = -1;
if (t)
{
while (t[++i])
free(t[i]);
free(t);
}
return (0);
}