-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdezalocari.c
51 lines (36 loc) · 946 Bytes
/
dezalocari.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
/* TRIFU-URZICĂ Alexandru - 315CB */
#include "header.h"
/* dezalocă matricea de pixeli */
void dezalocGrid(Pixel ***grid, int height) {
for (int i = 0; i < height; i++) {
free((*grid)[i]);
}
free(*grid);
*grid = NULL;
}
void distruge(TArb arb) /* functie auxiliara - distruge toate nodurile */
{
if (!arb) return;
distruge(arb->unu); /* distruge subarborele 1 */
distruge(arb->doi); /* distruge subarborele 2 */
distruge(arb->trei); /* distruge subarborele 3 */
distruge(arb->patru); /* distruge subarborele 4 */
free(arb); /* distruge nodul radacina */
}
void DistrArb(TArb *a) /* distruge toate nodurile arborelui de la adresa a */
{
if (!(*a)) return; /* arbore deja vid */
distruge(*a); /* distruge toate nodurile */
*a = NULL; /* arborele este vid */
}
void dezalocQ(TCoada **coada) {
TLista p, aux;
p = (*coada)->inc;
while(p) {
aux = p;
p = p->urm;
free(aux);
}
free(*coada);
*coada = NULL;
}