10 |
extern mboxgrp_t *mboxgrps; |
extern mboxgrp_t *mboxgrps; |
11 |
extern filter_t *filters; |
extern filter_t *filters; |
12 |
|
|
13 |
extern account_t *cur_acct; |
extern account_t *curacct; |
14 |
extern filter_t *cur_fltr; |
extern filter_t *curfltr; |
15 |
|
|
16 |
|
|
17 |
void destroy_mboxgrps(mboxgrp_t * node); |
void destroy_mboxgrps(mboxgrp_t * g); |
18 |
void destroy_mboxs(mbox_t * node); |
void destroy_mboxes(mbox_t * m); |
19 |
void destroy_accounts(account_t * node); |
void destroy_accounts(account_t * a); |
20 |
void destroy_filters(filter_t * node); |
void destroy_filters(filter_t * f); |
21 |
void destroy_masks(mask_t * node); |
void destroy_masks(mask_t * k); |
22 |
|
|
23 |
|
|
24 |
/* |
/* |
29 |
{ |
{ |
30 |
destroy_accounts(accounts); |
destroy_accounts(accounts); |
31 |
accounts = NULL; |
accounts = NULL; |
32 |
cur_acct = NULL; |
curacct = NULL; |
33 |
destroy_filters(filters); |
destroy_filters(filters); |
34 |
filters = NULL; |
filters = NULL; |
35 |
cur_fltr = NULL; |
curfltr = NULL; |
36 |
destroy_mboxgrps(mboxgrps); |
destroy_mboxgrps(mboxgrps); |
37 |
mboxgrps = NULL; |
mboxgrps = NULL; |
38 |
} |
} |
54 |
* each node. |
* each node. |
55 |
*/ |
*/ |
56 |
void |
void |
57 |
destroy_mboxgrps(mboxgrp_t * node) |
destroy_mboxgrps(mboxgrp_t * g) |
58 |
{ |
{ |
59 |
if (node == NULL) |
if (g == NULL) |
60 |
return; |
return; |
61 |
|
|
62 |
if (node->left != NULL) { |
if (g->left != NULL) { |
63 |
destroy_mboxgrps(node->left); |
destroy_mboxgrps(g->left); |
64 |
node->left = NULL; |
g->left = NULL; |
65 |
} |
} |
66 |
if (node->right != NULL) { |
if (g->right != NULL) { |
67 |
destroy_mboxgrps(node->right); |
destroy_mboxgrps(g->right); |
68 |
node->right = NULL; |
g->right = NULL; |
69 |
} |
} |
70 |
debug("deleting FOLDER: '%s'\n", node->key); |
debug("deleting folder: '%s'\n", g->key); |
71 |
|
|
72 |
xfree(node); |
xfree(g); |
73 |
} |
} |
74 |
|
|
75 |
|
|
78 |
* memory of each node. |
* memory of each node. |
79 |
*/ |
*/ |
80 |
void |
void |
81 |
destroy_mboxs(mbox_t * node) |
destroy_mboxes(mbox_t * m) |
82 |
{ |
{ |
83 |
mbox_t *p, *t; |
mbox_t *p, *t; |
84 |
|
|
85 |
for (p = node; p != NULL; p = t) { |
for (p = m; p != NULL; p = t) { |
86 |
t = p->next; |
t = p->next; |
87 |
debug("deleting MBOX: '%s'\n", p->name); |
debug("deleting mbox: '%s'\n", p->name); |
88 |
xfree(p); |
xfree(p); |
89 |
} |
} |
90 |
} |
} |
95 |
* each node. |
* each node. |
96 |
*/ |
*/ |
97 |
void |
void |
98 |
destroy_accounts(account_t * node) |
destroy_accounts(account_t * a) |
99 |
{ |
{ |
100 |
account_t *p, *t; |
account_t *p, *t; |
101 |
|
|
102 |
for (p = node; p != NULL; p = t) { |
for (p = a; p != NULL; p = t) { |
103 |
t = p->next; |
t = p->next; |
104 |
debug("deleting ACCOUNT: '%s'\n", p->key); |
debug("deleting account: '%s'\n", p->key); |
105 |
destroy_mboxs(p->mboxes); |
destroy_mboxes(p->mboxes); |
106 |
sfree(p->password); |
sfree(p->pass); |
107 |
xfree(p); |
xfree(p); |
108 |
} |
} |
109 |
} |
} |
113 |
* Go through the filters' tree and free the allocated memory of each node. |
* Go through the filters' tree and free the allocated memory of each node. |
114 |
*/ |
*/ |
115 |
void |
void |
116 |
destroy_filters(filter_t * node) |
destroy_filters(filter_t * f) |
117 |
{ |
{ |
118 |
if (node == NULL) |
if (f == NULL) |
119 |
return; |
return; |
120 |
|
|
121 |
if (node->left != NULL) { |
if (f->left != NULL) { |
122 |
destroy_filters(node->left); |
destroy_filters(f->left); |
123 |
node->left = NULL; |
f->left = NULL; |
124 |
} |
} |
125 |
if (node->right != NULL) { |
if (f->right != NULL) { |
126 |
destroy_filters(node->right); |
destroy_filters(f->right); |
127 |
node->right = NULL; |
f->right = NULL; |
128 |
} |
} |
129 |
debug("deleting FILTER: '%s'\n", node->key); |
debug("deleting filter: '%s'\n", f->key); |
130 |
destroy_masks(node->masks); |
destroy_masks(f->masks); |
131 |
xfree(node); |
xfree(f); |
132 |
} |
} |
133 |
|
|
134 |
|
|
137 |
* node. |
* node. |
138 |
*/ |
*/ |
139 |
void |
void |
140 |
destroy_masks(mask_t * node) |
destroy_masks(mask_t * k) |
141 |
{ |
{ |
142 |
mask_t *p, *t; |
mask_t *p, *t; |
143 |
|
|
144 |
for (p = node; p != NULL; p = t) { |
for (p = k; p != NULL; p = t) { |
145 |
t = p->next; |
t = p->next; |
146 |
debug("deleting MASK: '%s'\n", p->body); |
debug("deleting mask: '%s'\n", p->body); |
147 |
xfree(p); |
xfree(p); |
148 |
} |
} |
149 |
} |
} |