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>
15 /* The list of top-level contents to display */
21 void free_content(CT);
24 void free_encoding(CT, int);
30 static void free_text(CT);
31 static void free_multi(CT);
32 static void free_partial(CT);
36 ** Primary routine to free a MIME content structure
46 ** free all the header fields
62 ** some of the content types have extra
63 ** parts which need to be freed.
71 if (ct->c_subtype == MESSAGE_PARTIAL) {
86 free(ct->c_storeproc);
91 /* free structures for content encodings */
119 ** Free the linked list of header fields
128 hp1 = ct->c_first_hf;
139 ct->c_first_hf = NULL;
140 ct->c_last_hf = NULL;
155 if (ci->ci_subtype) {
156 free(ci->ci_subtype);
157 ci->ci_subtype = NULL;
159 for (ap = ci->ci_attrs; *ap; ap++) {
163 if (ci->ci_comment) {
164 free(ci->ci_comment);
165 ci->ci_comment = NULL;
179 if (!(t = (struct text *) ct->c_ctparams))
183 ct->c_ctparams = NULL;
191 struct part *part, *next;
193 if (!(m = (struct multipart *) ct->c_ctparams))
201 for (part = m->mp_parts; part; part = next) {
202 next = part->mp_next;
203 free_content(part->mp_part);
209 ct->c_ctparams = NULL;
218 if (!(p = (struct partial *) ct->c_ctparams))
225 ct->c_ctparams = NULL;
230 ** Free data structures related to encoding/decoding
231 ** Content-Transfer-Encodings.
235 free_encoding(CT ct, int toplevel)
239 if (!(ce = ct->c_cefile))
258 ct->c_ceopenfnx = NULL;