]> diplodocus.org Git - nmh/blobdiff - uip/mhfree.c
Alter HasSuffixC()'s char * to be const.
[nmh] / uip / mhfree.c
index 4fb46da7403f9b8b6aa28ccd57f9d3468991adbc..dbb606f68eb06b7ad1ae9de1cad740d938a7425f 100644 (file)
@@ -9,6 +9,7 @@
  */
 
 #include <h/mh.h>
+#include <h/utils.h>
 #include <h/mime.h>
 #include <h/mhparse.h>
 
@@ -48,20 +49,10 @@ free_content (CT ct)
      */
     free_header (ct);
 
-    if (ct->c_partno) {
-       free (ct->c_partno);
-       ct->c_partno = NULL;
-    }
-
-    if (ct->c_vrsn) {
-       free (ct->c_vrsn);
-       ct->c_vrsn = NULL;
-    }
-
-    if (ct->c_ctline) {
-       free (ct->c_ctline);
-       ct->c_ctline = NULL;
-    }
+    mh_xfree(ct->c_partno);
+    mh_xfree(ct->c_vrsn);
+    mh_xfree(ct->c_ctline);
+    ct->c_partno = ct->c_vrsn = ct->c_ctline = NULL;
 
     free_ctinfo (ct);
 
@@ -91,43 +82,22 @@ free_content (CT ct)
            break;
     }
 
-    if (ct->c_showproc) {
-       free (ct->c_showproc);
-       ct->c_showproc = NULL;
-    }
-    if (ct->c_termproc) {
-       free (ct->c_termproc);
-       ct->c_termproc = NULL;
-    }
-    if (ct->c_storeproc) {
-       free (ct->c_storeproc);
-       ct->c_storeproc = NULL;
-    }
+    mh_xfree(ct->c_showproc);
+    mh_xfree(ct->c_termproc);
+    mh_xfree(ct->c_storeproc);
+    ct->c_showproc = ct->c_termproc = ct->c_storeproc = NULL;
 
-    if (ct->c_celine) {
-       free (ct->c_celine);
-       ct->c_celine = NULL;
-    }
+    mh_xfree(ct->c_celine);
+    ct->c_celine = NULL;
 
     /* free structures for content encodings */
     free_encoding (ct, 1);
 
-    if (ct->c_id) {
-       free (ct->c_id);
-       ct->c_id = NULL;
-    }
-    if (ct->c_descr) {
-       free (ct->c_descr);
-       ct->c_descr = NULL;
-    }
-    if (ct->c_dispo) {
-       free (ct->c_dispo);
-       ct->c_dispo = NULL;
-    }
-    if (ct->c_dispo_type) {
-       free (ct->c_dispo_type);
-       ct->c_dispo_type = NULL;
-    }
+    mh_xfree(ct->c_id);
+    mh_xfree(ct->c_descr);
+    mh_xfree(ct->c_dispo);
+    mh_xfree(ct->c_dispo_type);
+    ct->c_id = ct->c_descr = ct->c_dispo = ct->c_dispo_type = NULL;
     free_pmlist (&ct->c_dispo_first);
 
     if (ct->c_file) {
@@ -141,14 +111,9 @@ free_content (CT ct)
        ct->c_fp = NULL;
     }
 
-    if (ct->c_storage) {
-       free (ct->c_storage);
-       ct->c_storage = NULL;
-    }
-    if (ct->c_folder) {
-       free (ct->c_folder);
-       ct->c_folder = NULL;
-    }
+    mh_xfree(ct->c_storage);
+    mh_xfree(ct->c_folder);
+    ct->c_storage = ct->c_folder = NULL;
 
     free (ct);
 }
@@ -186,23 +151,13 @@ free_ctinfo (CT ct)
     CI ci;
 
     ci = &ct->c_ctinfo;
-    if (ci->ci_type) {
-       free (ci->ci_type);
-       ci->ci_type = NULL;
-    }
-    if (ci->ci_subtype) {
-       free (ci->ci_subtype);
-       ci->ci_subtype = NULL;
-    }
+    mh_xfree(ci->ci_type);
+    mh_xfree(ci->ci_subtype);
+    ci->ci_type = ci->ci_subtype = NULL;
     free_pmlist(&ci->ci_first_pm);
-    if (ci->ci_comment) {
-       free (ci->ci_comment);
-       ci->ci_comment = NULL;
-    }
-    if (ci->ci_magic) {
-       free (ci->ci_magic);
-       ci->ci_magic = NULL;
-    }
+    mh_xfree(ci->ci_comment);
+    mh_xfree(ci->ci_magic);
+    ci->ci_comment = ci->ci_magic = NULL;
 }
 
 
@@ -214,7 +169,7 @@ free_text (CT ct)
     if (!(t = (struct text *) ct->c_ctparams))
        return;
 
-    free ((char *) t);
+    free(t);
     ct->c_ctparams = NULL;
 }
 
@@ -228,21 +183,19 @@ free_multi (CT ct)
     if (!(m = (struct multipart *) ct->c_ctparams))
        return;
 
-    if (m->mp_start)
-       free (m->mp_start);
-    if (m->mp_stop)
-       free (m->mp_stop);
+    mh_xfree(m->mp_start);
+    mh_xfree(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;
        free_content (part->mp_part);
-       free ((char *) part);
+       free(part);
     }
     m->mp_parts = NULL;
 
-    free ((char *) m);
+    free(m);
     ct->c_ctparams = NULL;
 }
 
@@ -255,10 +208,9 @@ free_partial (CT ct)
     if (!(p = (struct partial *) ct->c_ctparams))
        return;
 
-    if (p->pm_partid)
-       free (p->pm_partid);
+    mh_xfree(p->pm_partid);
 
-    free ((char *) p);
+    free(p);
     ct->c_ctparams = NULL;
 }
 
@@ -272,12 +224,9 @@ free_external (CT ct)
        return;
 
     free_content (e->eb_content);
-    if (e->eb_body)
-       free (e->eb_body);
-    if (e->eb_url)
-       free (e->eb_url);
-
-    free ((char *) e);
+    mh_xfree(e->eb_body);
+    mh_xfree(e->eb_url);
+    free(e);
     ct->c_ctparams = NULL;
 }
 
@@ -288,14 +237,10 @@ free_pmlist (PM *p)
     PM pm = *p, 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);
+        mh_xfree(pm->pm_name);
+        mh_xfree(pm->pm_value);
+        mh_xfree(pm->pm_charset);
+        mh_xfree(pm->pm_lang);
        pm2 = pm->pm_next;
        free(pm);
        pm = pm2;