ctors/dtors for BODY's
[apps/madmutt.git] / lib-mime / mime.c
index 98237cf..212c24d 100644 (file)
@@ -20,7 +20,7 @@
 #include <lib-lib/ascii.h>
 #include <lib-lib/url.h>
 
-#include "mime-types.h"
+#include "mime.h"
 
 #include "mutt.h"
 
@@ -178,10 +178,36 @@ void envelope_wipe(ENVELOPE *p)
     string_list_wipe(&p->userhdrs);
 }
 
+void body_wipe(BODY *b)
+{
+    if (b->parameter)
+        parameter_list_wipe(&b->parameter);
+
+    if (b->unlink && b->filename) {
+        unlink (b->filename);
+    }
+
+    p_delete(&b->filename);
+    p_delete(&b->content);
+    p_delete(&b->xtype);
+    p_delete(&b->subtype);
+    p_delete(&b->description);
+    p_delete(&b->form_name);
+
+    if (b->hdr) {
+        /* Don't free twice (b->hdr->content = b->parts) */
+        b->hdr->content = NULL;
+        header_delete(&b->hdr);
+    }
+
+    if (b->parts)
+        body_list_wipe(&b->parts);
+}
+
 void header_wipe(HEADER *h)
 {
     envelope_delete(&h->env);
-    mutt_free_body (&h->content);
+    body_list_wipe(&h->content);
     p_delete(&h->maildir_flags);
     p_delete(&h->tree);
     p_delete(&h->path);