ctors/dtors for BODY's
authorPierre Habouzit <madcoder@debian.org>
Thu, 16 Nov 2006 00:13:44 +0000 (01:13 +0100)
committerPierre Habouzit <madcoder@debian.org>
Thu, 16 Nov 2006 00:13:44 +0000 (01:13 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
25 files changed:
attach.c
browser.c
commands.c
compose.c
copy.c
handler.c
hcache.c
lib-crypt/crypt-gpgme.c
lib-crypt/crypt.c
lib-crypt/pgp.c
lib-crypt/pgpkey.c
lib-crypt/smime.c
lib-mime/mime-types.h
lib-mime/mime.c
lib-mime/rfc822parse.c
mbox.c
mh.c
muttlib.c
nntp/nntp.c
pattern.c
postpone.c
protos.h
recvattach.c
send.c
sendlib.c

index 5e43321..88272b9 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -175,7 +175,7 @@ int mutt_compose_attachment (BODY * a)
               goto bailout;
             }
 
-            mutt_free_body (&b);
+            body_list_wipe(&b);
           }
         }
       }
index 7fc0335..69f95da 100644 (file)
--- a/browser.c
+++ b/browser.c
@@ -1339,7 +1339,7 @@ void _mutt_select_file (char *f, ssize_t flen, int flags, char ***files,
         b = mutt_make_file_attach (nbuf);
         if (b != NULL) {
           mutt_view_attachment (NULL, b, M_REGULAR, NULL, NULL, 0);
-          mutt_free_body (&b);
+          body_list_wipe(&b);
           menu->redraw = REDRAW_FULL;
         }
         else
index d276022..b521342 100644 (file)
@@ -893,7 +893,7 @@ void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
   b->force_charset |= charset_changed ? 1 : 0;
 
   if (!is_multipart(b) && b->parts)
-    mutt_free_body (&b->parts);
+    body_list_wipe(&b->parts);
   if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
     b->hdr->content = NULL;
     header_delete(&b->hdr);
index ca5704b..de3e38b 100644 (file)
--- a/compose.c
+++ b/compose.c
@@ -366,7 +366,7 @@ static int delete_attachment (MUTTMENU * menu, short *idxlen, int x)
 
   idx[x]->content->next = NULL;
   idx[x]->content->parts = NULL;
-  mutt_free_body (&(idx[x]->content));
+  body_list_wipe(&(idx[x]->content));
   p_delete(&idx[x]->tree);
   p_delete(&idx[x]);
   for (; x < *idxlen - 1; x++)
@@ -1260,7 +1260,7 @@ int mutt_compose_menu (HEADER * msg,    /* structure for new message */
           idx[idxlen]->content->parts = NULL;
           if (idx[idxlen]->unowned)
             idx[idxlen]->content->unlink = 0;
-          mutt_free_body (&idx[idxlen]->content);
+          body_list_wipe(&idx[idxlen]->content);
           p_delete(&idx[idxlen]->tree);
           p_delete(&idx[idxlen]);
         }
diff --git a/copy.c b/copy.c
index 42543d3..ccbf308 100644 (file)
--- a/copy.c
+++ b/copy.c
@@ -571,7 +571,7 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body,
           Context->vsize -= body->length - new_length;
 
         body->length = new_length;
-        mutt_free_body (&body->parts);
+        body_list_wipe(&body->parts);
       }
 
       return 0;
@@ -630,10 +630,10 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body,
     fseeko (fp, cur->offset, 0);
     if (mutt_copy_bytes (fp, fpout, cur->length) == -1) {
       fclose (fp);
-      mutt_free_body (&cur);
+      body_list_wipe(&cur);
       return (-1);
     }
-    mutt_free_body (&cur);
+    body_list_wipe(&cur);
     fclose (fp);
   }
   else {
@@ -658,7 +658,7 @@ _mutt_copy_message (FILE * fpout, FILE * fpin, HEADER * hdr, BODY * body,
   if ((flags & M_CM_UPDATE) && (flags & M_CM_NOHEADER) == 0
       && new_offset != -1) {
     body->offset = new_offset;
-    mutt_free_body (&body->parts);
+    body_list_wipe(&body->parts);
   }
 
   return rc;
index 5d9af6d..47cbaca 100644 (file)
--- a/handler.c
+++ b/handler.c
@@ -781,7 +781,7 @@ static int alternative_handler (BODY * a, STATE * s)
 
     mustfree = 1;
     fstat (fileno (s->fpin), &st);
-    b = mutt_new_body ();
+    b = body_new();
     b->length = (long) st.st_size;
     b->parts = mutt_parse_multipart(s->fpin,
                                     parameter_getval(a->parameter, "boundary"),
@@ -903,7 +903,7 @@ static int alternative_handler (BODY * a, STATE * s)
   }
 
   if (mustfree)
-    mutt_free_body (&a);
+    body_list_wipe(&a);
 
   return (rc);
 }
@@ -920,7 +920,7 @@ static int message_handler (BODY * a, STATE * s)
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
       a->encoding == ENCUUENCODED) {
     fstat (fileno (s->fpin), &st);
-    b = mutt_new_body ();
+    b = body_new();
     b->length = (long) st.st_size;
     b->parts = mutt_parse_messageRFC822 (s->fpin, b);
   }
@@ -944,7 +944,7 @@ static int message_handler (BODY * a, STATE * s)
 
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
       a->encoding == ENCUUENCODED)
-    mutt_free_body (&b);
+    body_list_wipe(&b);
 
   return (rc);
 }
@@ -995,7 +995,7 @@ static int multipart_handler (BODY * a, STATE * s)
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
       a->encoding == ENCUUENCODED) {
     fstat (fileno (s->fpin), &st);
-    b = mutt_new_body ();
+    b = body_new();
     b->length = (long) st.st_size;
     b->parts = mutt_parse_multipart(s->fpin,
                                     parameter_getval(a->parameter, "boundary"),
@@ -1045,7 +1045,7 @@ static int multipart_handler (BODY * a, STATE * s)
 
   if (a->encoding == ENCBASE64 || a->encoding == ENCQUOTEDPRINTABLE ||
       a->encoding == ENCUUENCODED)
-    mutt_free_body (&b);
+    body_list_wipe(&b);
 
   return (rc);
 }
index 7b0f6d2..a757415 100644 (file)
--- a/hcache.c
+++ b/hcache.c
@@ -504,7 +504,7 @@ HEADER *mutt_hcache_restore (const unsigned char *d, HEADER ** oh)
   h->env = envelope_new();
   restore_envelope (h->env, d, &off);
 
-  h->content = mutt_new_body ();
+  h->content = body_new();
   restore_body (h->content, d, &off);
 
   restore_char (&h->maildir_flags, d, &off);
index 3afaea0..8cb8341 100644 (file)
@@ -758,7 +758,7 @@ static BODY *sign_message (BODY * a, int use_smime)
     return NULL;
   }
 
-  t = mutt_new_body ();
+  t = body_new();
   t->type = TYPEMULTIPART;
   t->subtype = m_strdup("signed");
   t->encoding = ENC7BIT;
@@ -780,7 +780,7 @@ static BODY *sign_message (BODY * a, int use_smime)
   t->parts = a;
   a = t;
 
-  t->parts->next = mutt_new_body ();
+  t->parts->next = body_new();
   t = t->parts->next;
   t->type = TYPEAPPLICATION;
   if (use_smime) {
@@ -845,7 +845,7 @@ BODY *pgp_gpgme_encrypt_message (BODY * a, char *keylist, int sign)
   if (!outfile)
     return NULL;
 
-  t = mutt_new_body ();
+  t = body_new();
   t->type = TYPEMULTIPART;
   t->subtype = m_strdup("encrypted");
   t->encoding = ENC7BIT;
@@ -855,12 +855,12 @@ BODY *pgp_gpgme_encrypt_message (BODY * a, char *keylist, int sign)
   parameter_set_boundary(&t->parameter);
   parameter_setval(&t->parameter, "protocol", "application/pgp-encrypted");
 
-  t->parts = mutt_new_body ();
+  t->parts = body_new();
   t->parts->type = TYPEAPPLICATION;
   t->parts->subtype = m_strdup("pgp-encrypted");
   t->parts->encoding = ENC7BIT;
 
-  t->parts->next = mutt_new_body ();
+  t->parts->next = body_new();
   t->parts->next->type = TYPEAPPLICATION;
   t->parts->next->subtype = m_strdup("octet-stream");
   t->parts->next->encoding = ENC7BIT;
@@ -903,7 +903,7 @@ BODY *smime_gpgme_build_smime_entity (BODY * a, char *keylist)
   if (!outfile)
     return NULL;
 
-  t = mutt_new_body ();
+  t = body_new();
   t->type = TYPEAPPLICATION;
   t->subtype = m_strdup("pkcs7-mime");
   parameter_setval(&t->parameter, "name", "smime.p7m");
@@ -1618,7 +1618,7 @@ int smime_gpgme_decrypt_mime (FILE * fpin, FILE ** fpout, BODY * b,
     bb->offset = saved_b_offset;
     fclose (tmpfp);
     rewind (*fpout);
-    mutt_free_body (cur);
+    body_list_wipe(cur);
     *cur = tmp_b;
   }
   return *cur ? 0 : -1;
@@ -2056,7 +2056,7 @@ int pgp_gpgme_encrypted_handler (BODY * a, STATE * s)
                          : _("[-- End of PGP/MIME encrypted data --]\n"), s);
     }
 
-    mutt_free_body (&tattach);
+    body_list_wipe(&tattach);
   }
 
   fclose (fpout);
@@ -2120,7 +2120,7 @@ int smime_gpgme_application_handler (BODY * a, STATE * s)
                          _("[-- End of S/MIME encrypted data --]\n"), s);
     }
 
-    mutt_free_body (&tattach);
+    body_list_wipe(&tattach);
   }
 
   fclose (fpout);
index 57021b1..eb60a2d 100644 (file)
@@ -194,7 +194,7 @@ int mutt_protect (HEADER * msg, char *keylist)
            which tmp_smime_pbody->parts after signing. */
         tmp_smime_pbody->parts = tmp_smime_pbody->parts->next;
         msg->content->next = NULL;
-        mutt_free_body (&tmp_smime_pbody);
+        body_list_wipe(&tmp_smime_pbody);
       }
       pbody = tmp_pbody;
     }
@@ -208,7 +208,7 @@ int mutt_protect (HEADER * msg, char *keylist)
           /* remove the outer multipart layer */
           tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
           /* get rid of the signature */
-          mutt_free_body (&tmp_pgp_pbody->next);
+          body_list_wipe(&tmp_pgp_pbody->next);
         }
 
         return (-1);
@@ -220,7 +220,7 @@ int mutt_protect (HEADER * msg, char *keylist)
        */
       if (flags != msg->security) {
         tmp_pgp_pbody = mutt_remove_multipart (tmp_pgp_pbody);
-        mutt_free_body (&tmp_pgp_pbody->next);
+        body_list_wipe(&tmp_pgp_pbody->next);
       }
     }
   }
index 1cbcc6f..408bf33 100644 (file)
@@ -914,7 +914,7 @@ int pgp_encrypted_handler (BODY * a, STATE * s)
       state_attach_puts (_("[-- End of PGP/MIME encrypted data --]\n"), s);
     }
 
-    mutt_free_body (&tattach);
+    body_list_wipe(&tattach);
     /* clear 'Invoking...' message, since there's no error */
     mutt_message _("PGP message successfully decrypted.");
   } else {
@@ -1023,7 +1023,7 @@ BODY *pgp_sign_message (BODY * a)
     return (NULL);              /* fatal error while signing */
   }
 
-  t = mutt_new_body ();
+  t = body_new();
   t->type = TYPEMULTIPART;
   t->subtype = m_strdup("signed");
   t->encoding = ENC7BIT;
@@ -1037,7 +1037,7 @@ BODY *pgp_sign_message (BODY * a)
   t->parts = a;
   a = t;
 
-  t->parts->next = mutt_new_body ();
+  t->parts->next = body_new();
   t = t->parts->next;
   t->type = TYPEAPPLICATION;
   t->subtype = m_strdup("pgp-signature");
@@ -1269,7 +1269,7 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign)
     return (NULL);
   }
 
-  t = mutt_new_body ();
+  t = body_new();
   t->type = TYPEMULTIPART;
   t->subtype = m_strdup("encrypted");
   t->encoding = ENC7BIT;
@@ -1279,12 +1279,12 @@ BODY *pgp_encrypt_message (BODY * a, char *keylist, int sign)
   parameter_set_boundary(&t->parameter);
   parameter_setval(&t->parameter, "protocol", "application/pgp-encrypted");
 
-  t->parts = mutt_new_body ();
+  t->parts = body_new();
   t->parts->type = TYPEAPPLICATION;
   t->parts->subtype = m_strdup("pgp-encrypted");
   t->parts->encoding = ENC7BIT;
 
-  t->parts->next = mutt_new_body ();
+  t->parts->next = body_new();
   t->parts->next->type = TYPEAPPLICATION;
   t->parts->next->subtype = m_strdup("octet-stream");
   t->parts->next->encoding = ENC7BIT;
@@ -1437,7 +1437,7 @@ BODY *pgp_traditional_encryptsign (BODY * a, int flags, char *keylist)
     return NULL;
   }
 
-  b = mutt_new_body ();
+  b = body_new();
 
   b->encoding = ENC7BIT;
 
index a4549cf..762842b 100644 (file)
@@ -738,7 +738,7 @@ BODY *pgp_make_key_attachment (char *tempf)
   fclose (tempfp);
   fclose (devnull);
 
-  att = mutt_new_body ();
+  att = body_new();
   att->filename = m_strdup(tempf);
   att->unlink = 1;
   att->use_disp = 0;
index fa7feac..f96b31d 100644 (file)
@@ -1304,7 +1304,7 @@ BODY *smime_build_smime_entity (BODY * a, char *certlist)
     return (NULL);
   }
 
-  t = mutt_new_body ();
+  t = body_new();
   t->type = TYPEAPPLICATION;
   t->subtype = m_strdup("x-pkcs7-mime");
   parameter_setval(&t->parameter, "name", "smime.p7m");
@@ -1420,7 +1420,7 @@ BODY *smime_sign_message (BODY * a)
     return (NULL);              /* fatal error while signing */
   }
 
-  t = mutt_new_body ();
+  t = body_new();
   t->type = TYPEMULTIPART;
   t->subtype = m_strdup("signed");
   t->encoding = ENC7BIT;
@@ -1436,7 +1436,7 @@ BODY *smime_sign_message (BODY * a)
   t->parts = a;
   a = t;
 
-  t->parts->next = mutt_new_body ();
+  t->parts->next = body_new();
   t = t->parts->next;
   t->type = TYPEAPPLICATION;
   t->subtype = m_strdup("x-pkcs7-signature");
index 03d654a..f04986a 100644 (file)
@@ -183,6 +183,8 @@ typedef struct content {
 /****************************************************************************/
 
 typedef struct body {
+    struct body *next;            /* next attachment in the list */
+
     char *xtype;                  /* content-type if x-unknown */
     char *subtype;                /* content-type subtype */
     parameter_t *parameter;         /* parameters of the content-type */
@@ -209,7 +211,6 @@ typedef struct body {
                                    * to determine what content-transfer-encoding
                                    * is required when sending mail.
                                    */
-    struct body *next;            /* next attachment in the list */
     struct body *parts;           /* parts of a multipart or message/rfc822 */
     struct header *hdr;           /* header information for message/rfc822 */
 
@@ -253,6 +254,17 @@ typedef struct body {
     unsigned int attach_qualifies:1;
 } BODY;
 
+static inline BODY *body_init(BODY *b) {
+    b->disposition = DISPATTACH;
+    b->use_disp = 1;
+    return b;
+}
+void body_wipe(BODY *);
+
+DO_NEW(BODY, body);
+DO_DELETE(BODY, body);
+DO_SLIST(BODY, body, body_delete);
+
 
 /****************************************************************************/
 /* rfc822 Headers                                                           */
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);
index 31b5d88..33012fd 100644 (file)
@@ -384,7 +384,7 @@ static void parse_content_disposition(const char *s, BODY *ct)
  */
 BODY *mutt_read_mime_header(FILE *fp, int digest)
 {
-    BODY *body = mutt_new_body ();
+    BODY *body = body_new();
     char *line = p_new(char, LONG_STRING);
     ssize_t linelen = LONG_STRING;
     char *p;
@@ -573,7 +573,7 @@ mutt_parse_multipart(FILE *fp, const char *bound, off_t end_off, int digest)
                  */
 
                 if (new->offset > end_off) {
-                    mutt_free_body(&new);
+                    body_list_wipe(&new);
                     break;
                 }
 
@@ -1018,7 +1018,7 @@ mutt_read_rfc822_header(FILE *f, HEADER *hdr, short user_hdrs, short weed)
     off_t loc;
 
     if (hdr && !hdr->content) {
-        hdr->content = mutt_new_body ();
+        hdr->content = body_new();
 
         /* set the defaults from RFC1521 */
         hdr->content->type     = TYPETEXT;
diff --git a/mbox.c b/mbox.c
index 618fbdf..8b5b577 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -657,7 +657,7 @@ static int _mbox_sync_mailbox (CONTEXT * ctx, int unused __attribute__ ((unused)
        */
       newOffset[i - first].body =
         ftello (fp) - ctx->hdrs[i]->content->length + offset;
-      mutt_free_body (&ctx->hdrs[i]->content->parts);
+      body_list_wipe(&ctx->hdrs[i]->content->parts);
 
       switch (ctx->magic) {
       case M_MMDF:
diff --git a/mh.c b/mh.c
index 49302fc..3df675b 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -1206,7 +1206,7 @@ static int mh_rewrite_message (CONTEXT * ctx, int msgno)
     h->lines = old_hdr_lines;
   }
 
-  mutt_free_body (&h->content->parts);
+  body_list_wipe(&h->content->parts);
   return rc;
 }
 
index cffef19..fc9606d 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
 
 #define SW              (option(OPTMBOXPANE)?SidebarWidth:0)
 
-BODY *mutt_new_body (void)
-{
-  BODY *p = p_new(BODY, 1);
-
-  p->disposition = DISPATTACH;
-  p->use_disp = 1;
-  return (p);
-}
-
-
 /* Modified by blong to accept a "suggestion" for file name.  If
  * that file exists, then construct one with unique name but 
  * keep any extension.  This might fail, I guess.
@@ -125,7 +115,7 @@ int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
   if (mutt_save_attachment (fp, src, tmp, 0, NULL) == -1)
     return -1;
 
-  *tgt = mutt_new_body ();
+  *tgt = body_new();
   b = *tgt;
 
   memcpy (b, src, sizeof (BODY));
@@ -167,45 +157,6 @@ int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
   return 0;
 }
 
-
-static 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)
-        mutt_free_body(&b->parts);
-}
-
-DO_DELETE(BODY, body);
-
-void mutt_free_body(BODY **p)
-{
-    while (*p) {
-        BODY *b = *p;
-        *p = b->next;
-
-        body_delete(&b);
-    }
-}
-
 HEADER *mutt_dup_header (HEADER * h)
 {
   HEADER *hnew;
index 1432523..f576fc0 100644 (file)
@@ -540,7 +540,7 @@ static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr)
 
   hdr->env = envelope_new();
   hdr->env->newsgroups = m_strdup(nntp_data->group);
-  hdr->content = mutt_new_body ();
+  hdr->content = body_new();
   hdr->content->type = TYPETEXT;
   hdr->content->subtype = m_strdup("plain");
   hdr->content->encoding = ENC7BIT;
index cef1722..32a5094 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -1090,7 +1090,7 @@ mutt_pattern_exec (struct pattern_t *pat, pattern_exec_flag flags,
       else {
         mutt_parse_mime_message(ctx, h);
         count = mutt_count_body_parts(h, 0);
-        mutt_free_body(&h->content->parts);
+        body_list_wipe(&h->content->parts);
       }
       
       return (pat->not ^ (count >= pat->min && (pat->max == M_MAXRANGE ||
index cb51271..174d8e1 100644 (file)
@@ -537,13 +537,13 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr,
     err:
       mx_close_message (&msg);
       envelope_delete(&newhdr->env);
-      mutt_free_body (&newhdr->content);
+      body_list_wipe(&newhdr->content);
       mutt_error _("Decryption failed.");
 
       return -1;
     }
 
-    mutt_free_body (&newhdr->content);
+    body_list_wipe(&newhdr->content);
     newhdr->content = b;
 
     mutt_clear_error ();
@@ -563,7 +563,7 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr,
       newhdr->security |= APPLICATION_SMIME;
 
     /* destroy the signature */
-    mutt_free_body (&newhdr->content->parts->next);
+    body_list_wipe(&newhdr->content->parts->next);
     newhdr->content = mutt_remove_multipart (newhdr->content);
   }
 
@@ -642,7 +642,7 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr,
 
     mutt_stamp_attachment (b);
 
-    mutt_free_body (&b->parts);
+    body_list_wipe(&b->parts);
     if (b->hdr)
       b->hdr->content = NULL;   /* avoid dangling pointer */
   }
@@ -674,7 +674,7 @@ bail:
 
   if (rv == -1) {
     envelope_delete(&newhdr->env);
-    mutt_free_body (&newhdr->content);
+    body_list_wipe(&newhdr->content);
   }
 
   return rv;
index 5633b94..0c03558 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -51,7 +51,6 @@ BODY *mutt_make_file_attach (const char *);
 BODY *mutt_make_message_attach (CONTEXT *, HEADER *, int);
 BODY *mutt_remove_multipart (BODY *);
 BODY *mutt_make_multipart (BODY *);
-BODY *mutt_new_body(void);
 
 CONTENT *mutt_get_content_info (const char *fname, BODY * b);
 
@@ -112,7 +111,6 @@ void mutt_format_s (char *, ssize_t, const char *, const char *);
 void mutt_format_s_tree (char *, ssize_t, const char *, const char *);
 void mutt_forward_intro (FILE * fp, HEADER * cur);
 void mutt_forward_trailer (FILE * fp);
-void mutt_free_body (BODY **);
 void mutt_free_color (int fg, int bg);
 void mutt_generate_header (char *, ssize_t, HEADER *, int);
 void mutt_help (int);
index bc59c76..b456131 100644 (file)
@@ -952,7 +952,7 @@ void mutt_view_attachments (HEADER * hdr)
           cur = NULL;
           secured = !crypt_smime_decrypt_mime (_fp, &fp, _cur, &cur);
 
-          mutt_free_body (&_cur);
+          body_list_wipe(&_cur);
           safe_fclose (&_fp);
         }
       }
@@ -1244,7 +1244,7 @@ void mutt_view_attachments (HEADER * hdr)
 
       if (need_secured && secured) {
         fclose (fp);
-        mutt_free_body (&cur);
+        body_list_wipe(&cur);
       }
 
       mutt_menuDestroy (&menu);
diff --git a/send.c b/send.c
index 2ab5e0f..2d05c43 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1178,7 +1178,7 @@ int ci_send_message (int flags, /* send mode */
   }
 
   if (!(flags & (SENDKEY | SENDPOSTPONED | SENDRESEND))) {
-    pbody = mutt_new_body ();
+    pbody = body_new();
     pbody->next = msg->content; /* don't kill command-line attachments */
     msg->content = pbody;
 
@@ -1725,10 +1725,10 @@ int ci_send_message (int flags, /* send mode */
     if (save_sig) {
       /* cleanup the second signature structures */
       if (save_content->parts) {
-        mutt_free_body (&save_content->parts->next);
+        body_list_wipe(&save_content->parts->next);
         save_content->parts = NULL;
       }
-      mutt_free_body (&save_content);
+      body_list_wipe(&save_content);
 
       /* restore old signature and attachments */
       msg->content->parts->next = save_sig;
@@ -1736,7 +1736,7 @@ int ci_send_message (int flags, /* send mode */
     }
     else if (save_content) {
       /* destroy the new encrypted body. */
-      mutt_free_body (&save_content);
+      body_list_wipe(&save_content);
     }
 
   }
@@ -1752,11 +1752,11 @@ int ci_send_message (int flags, /* send mode */
       if ((msg->security & ENCRYPT)
       ||  ((msg->security & SIGN)
       &&  msg->content->type == TYPEAPPLICATION)) {
-        mutt_free_body (&msg->content); /* destroy PGP data */
+        body_list_wipe(&msg->content); /* destroy PGP data */
         msg->content = clear_content;   /* restore clear text. */
       }
       else if ((msg->security & SIGN) && msg->content->type == TYPEMULTIPART) {
-        mutt_free_body (&msg->content->parts->next);    /* destroy sig */
+        body_list_wipe(&msg->content->parts->next);    /* destroy sig */
         msg->content = mutt_remove_multipart (msg->content);
       }
 
@@ -1784,7 +1784,7 @@ int ci_send_message (int flags, /* send mode */
     p_delete(&pgpkeylist);
 
   if (free_clear_content)
-    mutt_free_body (&clear_content);
+    body_list_wipe(&clear_content);
 
   if (flags & SENDREPLY) {
     if (cur && ctx)
index fbe8814..032078d 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1005,7 +1005,7 @@ cleanup:
     return;
   }
   a->length = sb.st_size;
-  mutt_free_body (&a->parts);
+  body_list_wipe(&a->parts);
   a->hdr->content = NULL;
 }
 
@@ -1172,7 +1172,7 @@ BODY *mutt_make_message_attach (CONTEXT * ctx, HEADER * hdr, int attach_msg)
   if ((fp = safe_fopen (buffer, "w+")) == NULL)
     return NULL;
 
-  body = mutt_new_body ();
+  body = body_new();
   body->type = TYPEMESSAGE;
   body->subtype = m_strdup("rfc822");
   body->filename = m_strdup(buffer);
@@ -1233,7 +1233,7 @@ BODY *mutt_make_file_attach (const char *path)
   BODY *att;
   CONTENT *info;
 
-  att = mutt_new_body ();
+  att = body_new();
   att->filename = m_strdup(path);
 
   /* Attempt to determine the appropriate content-type based on the filename
@@ -1257,7 +1257,7 @@ BODY *mutt_make_file_attach (const char *path)
 #endif
 
   if ((info = mutt_get_content_info (path, att)) == NULL) {
-    mutt_free_body (&att);
+    body_list_wipe(&att);
     return NULL;
   }
 
@@ -1299,7 +1299,7 @@ BODY *mutt_make_multipart (BODY * b)
 {
   BODY *new;
 
-  new = mutt_new_body ();
+  new = body_new();
   new->type = TYPEMULTIPART;
   new->subtype = m_strdup("mixed");
   new->encoding = get_toplevel_encoding (b);
@@ -1320,7 +1320,7 @@ BODY *mutt_remove_multipart (BODY * b)
     t = b;
     b = b->parts;
     t->parts = NULL;
-    mutt_free_body (&t);
+    body_list_wipe(&t);
   }
   return b;
 }