-
Notifications
You must be signed in to change notification settings - Fork 0
/
free.c
56 lines (45 loc) · 1011 Bytes
/
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
#include "free.h"
#include "solTree.h"
#include "heuristic.h"
#include "hide.h"
#include "initHrowLayout_Sudoku2.h"
void freeDance(Dance *d)
{
freeMatrix(d);
free(d->sols);
if(d->numSols > 0)
freeTree(d->csol);
if(d->problem == SUDOKU || d->problem == SUDOKU2 || d->problem == SGEN || d->problem == SUDOKU_O || d->problem == SGEN_O)
freeHide(d);
HEUR_FREE(d)
if(d->problem == SUDOKU || d->problem == SUDOKU2 || d->problem == SGEN || d->problem == SUDOKU_O || d->problem == SGEN_O)
{
fclose(d->s->boardFile);
free(d->s->grid);
free(d->s);
}
free(d);
}
void freeMatrix(Dance *d)
{
Doubly *col, *temp;
for(col = d->root->right; col != d->root;)
{
freeColumn(col);
temp = col;
col = col->right;
free(temp);
}
freeColumn(col);
free(d->root);
}
void freeColumn(Doubly *col)
{
Doubly *row, *temp;
for(row = col->down; row != col;)
{
temp = row;
row = row->down;
free(temp);
}
}