2 ** mhfree.c -- routines to free the data structures used to
3 ** -- represent MIME messages
5 ** This code is Copyright (c) 2002, by the authors of nmh. See the
6 ** COPYRIGHT file in the root directory of the nmh distribution for
7 ** complete copyright information.
14 #include <h/mhparse.h>
17 /* The list of top-level contents to display */
23 void free_content(CT);
26 void free_encoding(CT, int);
32 static void free_text(CT);
33 static void free_multi(CT);
34 static void free_partial(CT);
38 ** Primary routine to free a MIME content structure
48 ** free all the header fields
53 mh_free0(&(ct->c_partno));
56 mh_free0(&(ct->c_vrsn));
59 mh_free0(&(ct->c_ctline));
64 ** some of the content types have extra
65 ** parts which need to be freed.
73 if (ct->c_subtype == MESSAGE_PARTIAL) {
84 mh_free0(&(ct->c_charset));
86 mh_free0(&(ct->c_showproc));
88 mh_free0(&(ct->c_storeproc));
91 mh_free0(&(ct->c_celine));
93 /* free structures for content encodings */
97 mh_free0(&(ct->c_id));
99 mh_free0(&(ct->c_descr));
101 mh_free0(&(ct->c_dispo));
106 mh_free0(&(ct->c_file));
112 mh_free0(&(ct->c_storage));
114 mh_free0(&(ct->c_folder));
121 ** Free the linked list of header fields
130 hp1 = ct->c_first_hf;
134 mh_free0(&(hp1->name));
135 mh_free0(&(hp1->value));
141 ct->c_first_hf = NULL;
142 ct->c_last_hf = NULL;
154 mh_free0(&(ci->ci_type));
156 if (ci->ci_subtype) {
157 mh_free0(&(ci->ci_subtype));
159 for (ap = ci->ci_attrs; *ap; ap++) {
162 if (ci->ci_comment) {
163 mh_free0(&(ci->ci_comment));
166 mh_free0(&(ci->ci_magic));
176 if (!(t = (struct text *) ct->c_ctparams))
187 struct part *part, *next;
189 if (!(m = (struct multipart *) ct->c_ctparams))
193 mh_free0(&(m->mp_start));
195 mh_free0(&(m->mp_stop));
197 for (part = m->mp_parts; part; part = next) {
198 next = part->mp_next;
199 free_content(part->mp_part);
212 if (!(p = (struct partial *) ct->c_ctparams))
216 mh_free0(&(p->pm_partid));
223 ** Free data structures related to encoding/decoding
224 ** Content-Transfer-Encodings.
228 free_encoding(CT ct, int toplevel)
232 if (!(ce = ct->c_cefile))
243 mh_free0(&(ce->ce_file));
249 ct->c_ceopenfnx = NULL;