X-Git-Url: https://diplodocus.org/git/nmh/blobdiff_plain/6c42153ad9362cc676ea66563bf400d7511b3b68..edccf71caebd3979a2eef7993624ccc7dbf0691a:/uip/mhfree.c diff --git a/uip/mhfree.c b/uip/mhfree.c index 57518015..f2726d0f 100644 --- a/uip/mhfree.c +++ b/uip/mhfree.c @@ -3,27 +3,25 @@ * mhfree.c -- routines to free the data structures used to * -- represent MIME messages * - * $Id$ - * * This code is Copyright (c) 2002, by the authors of nmh. See the * COPYRIGHT file in the root directory of the nmh distribution for * complete copyright information. */ #include -#include #include #include -extern int errno; +/* The list of top-level contents to display */ +CT *cts = NULL; /* * prototypes */ -void free_content (CT); void free_header (CT); void free_ctinfo (CT); void free_encoding (CT, int); +void freects_done (int); /* * static prototypes @@ -32,6 +30,7 @@ static void free_text (CT); static void free_multi (CT); static void free_partial (CT); static void free_external (CT); +static void free_pmlist (PM); /* @@ -103,10 +102,15 @@ free_content (CT ct) free (ct->c_id); if (ct->c_descr) free (ct->c_descr); + if (ct->c_dispo) + free (ct->c_dispo); + if (ct->c_dispo_type) + free (ct->c_dispo_type); + free_pmlist (ct->c_dispo_first); if (ct->c_file) { if (ct->c_unlink) - unlink (ct->c_file); + (void) m_unlink (ct->c_file); free (ct->c_file); } if (ct->c_fp) @@ -150,7 +154,6 @@ free_header (CT ct) void free_ctinfo (CT ct) { - char **ap; CI ci; ci = &ct->c_ctinfo; @@ -162,10 +165,7 @@ free_ctinfo (CT ct) free (ci->ci_subtype); ci->ci_subtype = NULL; } - for (ap = ci->ci_attrs; *ap; ap++) { - free (*ap); - *ap = NULL; - } + free_pmlist(ci->ci_first_pm); if (ci->ci_comment) { free (ci->ci_comment); ci->ci_comment = NULL; @@ -203,6 +203,8 @@ free_multi (CT ct) free (m->mp_start); if (m->mp_stop) free (m->mp_stop); + free (m->mp_content_before); + free (m->mp_content_after); for (part = m->mp_parts; part; part = next) { next = part->mp_next; @@ -243,12 +245,35 @@ free_external (CT ct) free_content (e->eb_content); if (e->eb_body) free (e->eb_body); + if (e->eb_url) + free (e->eb_url); free ((char *) e); ct->c_ctparams = NULL; } +static void +free_pmlist (PM pm) +{ + PM pm2; + + while (pm != NULL) { + if (pm->pm_name) + free (pm->pm_name); + if (pm->pm_value) + free (pm->pm_value); + if (pm->pm_charset) + free (pm->pm_charset); + if (pm->pm_lang) + free (pm->pm_lang); + pm2 = pm->pm_next; + free(pm); + pm = pm2; + } +} + + /* * Free data structures related to encoding/decoding * Content-Transfer-Encodings. @@ -257,10 +282,7 @@ free_external (CT ct) void free_encoding (CT ct, int toplevel) { - CE ce; - - if (!(ce = ct->c_cefile)) - return; + CE ce = &ct->c_cefile; if (ce->ce_fp) { fclose (ce->ce_fp); @@ -269,14 +291,25 @@ free_encoding (CT ct, int toplevel) if (ce->ce_file) { if (ce->ce_unlink) - unlink (ce->ce_file); + (void) m_unlink (ce->ce_file); free (ce->ce_file); + ce->ce_file = NULL; } - if (toplevel) { - free ((char *) ce); - ct->c_cefile = NULL; - } else { + if (! toplevel) { ct->c_ceopenfnx = NULL; } } + + +void +freects_done (int status) +{ + CT *ctp; + + if ((ctp = cts)) + for (; *ctp; ctp++) + free_content (*ctp); + + exit (status); +}