]> diplodocus.org Git - nmh/blobdiff - uip/mhfree.c
Removed msh relics from scansbr.c, including a global.
[nmh] / uip / mhfree.c
index 2328b78a56c3251c1ad1032c2ee15f0da655a823..f2726d0fa88b3f46d22f356aa3ed2ae24fb7c99b 100644 (file)
@@ -9,7 +9,6 @@
  */
 
 #include <h/mh.h>
-#include <errno.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 
@@ -31,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);
 
 
 /*
@@ -104,10 +104,13 @@ free_content (CT ct)
        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)
@@ -151,7 +154,6 @@ free_header (CT ct)
 void
 free_ctinfo (CT ct)
 {
-    char **ap;
     CI ci;
 
     ci = &ct->c_ctinfo;
@@ -163,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;
@@ -254,6 +253,27 @@ free_external (CT ct)
 }
 
 
+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.
@@ -271,7 +291,7 @@ 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;
     }