/[imapfilter]/imapfilter/destroy.c
ViewVC logotype

Annotation of /imapfilter/destroy.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.7 - (hide annotations)
Sat Feb 14 19:14:43 2004 UTC (20 years, 2 months ago) by lefcha
Branch: MAIN
CVS Tags: HEAD
Changes since 1.6: +2 -2 lines
File MIME type: text/plain
Indentation.

1 lefcha 1.1 #include <stdio.h>
2    
3     #include "config.h"
4     #include "imapfilter.h"
5     #include "account.h"
6     #include "filter.h"
7    
8    
9     extern account_t *accounts;
10     extern mboxgrp_t *mboxgrps;
11     extern filter_t *filters;
12    
13 lefcha 1.5 extern account_t *curacct;
14     extern filter_t *curfltr;
15 lefcha 1.2
16 lefcha 1.1
17 lefcha 1.5 void destroy_mboxgrps(mboxgrp_t * g);
18     void destroy_mboxes(mbox_t * m);
19     void destroy_accounts(account_t * a);
20     void destroy_filters(filter_t * f);
21     void destroy_masks(mask_t * k);
22 lefcha 1.3
23    
24 lefcha 1.1 /*
25     * Free allocated memory of all data structures.
26     */
27     void
28     destroy_all(void)
29     {
30 lefcha 1.6
31 lefcha 1.1 destroy_accounts(accounts);
32     accounts = NULL;
33 lefcha 1.5 curacct = NULL;
34 lefcha 1.1 destroy_filters(filters);
35     filters = NULL;
36 lefcha 1.5 curfltr = NULL;
37 lefcha 1.1 destroy_mboxgrps(mboxgrps);
38     mboxgrps = NULL;
39     }
40    
41    
42     /*
43     * Free allocated memory of data structures that are not needed anymore.
44     */
45     void
46     destroy_unneeded(void)
47     {
48 lefcha 1.6
49 lefcha 1.1 destroy_mboxgrps(mboxgrps);
50     mboxgrps = NULL;
51     }
52    
53    
54     /*
55 lefcha 1.7 * Go through the mailbox-group tree, and free the allocated memory of each
56     * node.
57 lefcha 1.1 */
58     void
59 lefcha 1.5 destroy_mboxgrps(mboxgrp_t * g)
60 lefcha 1.1 {
61 lefcha 1.6
62 lefcha 1.5 if (g == NULL)
63 lefcha 1.1 return;
64    
65 lefcha 1.5 if (g->left != NULL) {
66     destroy_mboxgrps(g->left);
67     g->left = NULL;
68 lefcha 1.1 }
69 lefcha 1.5 if (g->right != NULL) {
70     destroy_mboxgrps(g->right);
71     g->right = NULL;
72 lefcha 1.1 }
73 lefcha 1.5 debug("deleting folder: '%s'\n", g->key);
74 lefcha 1.1
75 lefcha 1.5 xfree(g);
76 lefcha 1.1 }
77    
78    
79     /*
80     * Go through the mailbox linked list of the account and free the allocated
81     * memory of each node.
82     */
83     void
84 lefcha 1.5 destroy_mboxes(mbox_t * m)
85 lefcha 1.1 {
86     mbox_t *p, *t;
87    
88 lefcha 1.5 for (p = m; p != NULL; p = t) {
89 lefcha 1.1 t = p->next;
90 lefcha 1.5 debug("deleting mbox: '%s'\n", p->name);
91 lefcha 1.1 xfree(p);
92     }
93     }
94    
95    
96     /*
97     * Go through the accounts' linked list and free the allocated memory of
98     * each node.
99     */
100     void
101 lefcha 1.5 destroy_accounts(account_t * a)
102 lefcha 1.1 {
103     account_t *p, *t;
104    
105 lefcha 1.5 for (p = a; p != NULL; p = t) {
106 lefcha 1.1 t = p->next;
107 lefcha 1.5 debug("deleting account: '%s'\n", p->key);
108     destroy_mboxes(p->mboxes);
109     sfree(p->pass);
110 lefcha 1.1 xfree(p);
111     }
112     }
113    
114    
115     /*
116     * Go through the filters' tree and free the allocated memory of each node.
117     */
118     void
119 lefcha 1.5 destroy_filters(filter_t * f)
120 lefcha 1.1 {
121 lefcha 1.6
122 lefcha 1.5 if (f == NULL)
123 lefcha 1.1 return;
124    
125 lefcha 1.5 if (f->left != NULL) {
126     destroy_filters(f->left);
127     f->left = NULL;
128     }
129     if (f->right != NULL) {
130     destroy_filters(f->right);
131     f->right = NULL;
132     }
133     debug("deleting filter: '%s'\n", f->key);
134     destroy_masks(f->masks);
135     xfree(f);
136 lefcha 1.1 }
137    
138    
139     /*
140     * Go through the masks' linked list and free the allocated memory of each
141     * node.
142     */
143     void
144 lefcha 1.5 destroy_masks(mask_t * k)
145 lefcha 1.1 {
146     mask_t *p, *t;
147    
148 lefcha 1.5 for (p = k; p != NULL; p = t) {
149 lefcha 1.1 t = p->next;
150 lefcha 1.5 debug("deleting mask: '%s'\n", p->body);
151 lefcha 1.1 xfree(p);
152     }
153     }

webmaster@linux.gr
ViewVC Help
Powered by ViewVC 1.1.26