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.
13 #include <h/mhparse.h>
16 /* The list of top-level contents to display */
22 void free_content(CT);
25 void free_encoding(CT, int);
31 static void free_text(CT);
32 static void free_multi(CT);
33 static void free_partial(CT);
37 ** Primary routine to free a MIME content structure
47 ** free all the header fields
63 ** some of the content types have extra
64 ** parts which need to be freed.
72 if (ct->c_subtype == MESSAGE_PARTIAL) {
87 free(ct->c_storeproc);
92 /* free structures for content encodings */
120 ** Free the linked list of header fields
129 hp1 = ct->c_first_hf;
140 ct->c_first_hf = NULL;
141 ct->c_last_hf = NULL;
156 if (ci->ci_subtype) {
157 free(ci->ci_subtype);
158 ci->ci_subtype = NULL;
160 for (ap = ci->ci_attrs; *ap; ap++) {
164 if (ci->ci_comment) {
165 free(ci->ci_comment);
166 ci->ci_comment = NULL;
180 if (!(t = (struct text *) ct->c_ctparams))
184 ct->c_ctparams = NULL;
192 struct part *part, *next;
194 if (!(m = (struct multipart *) ct->c_ctparams))
202 for (part = m->mp_parts; part; part = next) {
203 next = part->mp_next;
204 free_content(part->mp_part);
210 ct->c_ctparams = NULL;
219 if (!(p = (struct partial *) ct->c_ctparams))
226 ct->c_ctparams = NULL;
231 ** Free data structures related to encoding/decoding
232 ** Content-Transfer-Encodings.
236 free_encoding(CT ct, int toplevel)
240 if (!(ce = ct->c_cefile))
259 ct->c_ceopenfnx = NULL;