-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsemantics.c
More file actions
93 lines (83 loc) · 2.08 KB
/
Copy pathsemantics.c
File metadata and controls
93 lines (83 loc) · 2.08 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* semantics.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: sescolas <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2017/02/25 17:20:08 by sescolas #+# #+# */
/* Updated: 2017/02/25 20:53:54 by sescolas ### ########.fr */
/* */
/* ************************************************************************** */
#include "fillit.h"
static void free_link(t_link *link)
{
--link->col->size;
link->u = NULL;
link->d = NULL;
link->l = NULL;
link->r = NULL;
link->col = NULL;
link->next_unlinked = NULL;
link = (void *)0;
free(link);
}
static void free_col(t_col *col)
{
t_link *tmp;
if (col->size == 0)
{
col->l = NULL;
col->r = NULL;
col->d = NULL;
col->root = NULL;
col->next_unlinked = NULL;
return ;
}
tmp = col->d;
col->d = col->d->d;
free_link(tmp);
free_col(col);
}
static void free_unlinked_cols(t_col *cols)
{
t_col *tmp;
if (cols == (void *)0)
return ;
tmp = cols;
cols = cols->next_unlinked;
free(tmp);
free_unlinked_cols(cols);
}
static void free_unlinked_links(t_link **links)
{
t_link *tmp;
if (*links == (void *)0)
{
free(*links);
links = (void *)0;
return ;
}
tmp = *links;
*links = (*links)->next_unlinked;
free(tmp);
free_unlinked_links(links);
}
void free_grid(t_col **grid, t_env *env)
{
t_col *tmp;
if (*grid == (void *)0)
{
free(grid);
free_unlinked_links(env->unlinked_links);
free_unlinked_cols(env->unlinked_cols);
return ;
}
tmp = *grid;
if (*grid == (*grid)->r)
*grid = (void *)0;
else
*grid = (*grid)->r;
free_col(tmp);
free_grid(grid, env);
}