use my own APIS for headers, parameters and so on
authorPierre Habouzit <madcoder@debian.org>
Sun, 5 Nov 2006 20:21:51 +0000 (21:21 +0100)
committerPierre Habouzit <madcoder@debian.org>
Sun, 5 Nov 2006 20:21:51 +0000 (21:21 +0100)
Signed-off-by: Pierre Habouzit <madcoder@debian.org>
25 files changed:
attach.c
buffy.c
commands.c
hcache.c
headers.c
imap/message.c
lib-mime/mime-types.h
lib-mime/mime.c
lib-mime/mime.h
lib-mime/rfc2231.c
lib-mime/rfc822address.c
lib-mime/rfc822parse.c
main.c
mbox.c
mh.c
muttlib.c
mx.c
nntp/nntp.c
pop/pop.c
postpone.c
protos.h
query.c
recvcmd.c
send.c
sendlib.c

index 3f6a9ac..d2ed956 100644 (file)
--- a/attach.c
+++ b/attach.c
@@ -142,7 +142,7 @@ int mutt_compose_attachment (BODY * a)
           b = mutt_read_mime_header (fp, 0);
           if (b) {
             if (b->parameter) {
-              mutt_free_parameter (&a->parameter);
+              parameter_delete(&a->parameter);
               a->parameter = b->parameter;
               b->parameter = NULL;
             }
@@ -865,7 +865,7 @@ int mutt_decode_save_attachment (FILE * fp, BODY * m, char *path,
     m->length = 0;
     m->encoding = saved_encoding;
     if (saved_parts) {
-      mutt_free_header (&m->hdr);
+      header_delete(&m->hdr);
       m->parts = saved_parts;
       m->hdr = saved_hdr;
     }
diff --git a/buffy.c b/buffy.c
index 105e809..6dd5457 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -100,13 +100,13 @@ static int test_last_status_new (FILE * f)
   if (fseeko_last_message (f) == -1)
     return (0);
 
-  hdr = mutt_new_header ();
+  hdr = header_new();
   tmp_envelope = mutt_read_rfc822_header (f, hdr, 0, 0);
   if (!(hdr->read || hdr->old))
     result = 1;
 
-  mutt_free_envelope (&tmp_envelope);
-  mutt_free_header (&hdr);
+  envelope_delete(&tmp_envelope);
+  header_delete(&hdr);
 
   return result;
 }
index 83604ca..34de35e 100644 (file)
@@ -854,7 +854,7 @@ void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
     return;
 
   /* clean up previous junk */
-  mutt_free_parameter (&b->parameter);
+  parameter_delete(&b->parameter);
   p_delete(&b->subtype);
 
   mutt_parse_content_type (buf, b);
@@ -895,7 +895,7 @@ void mutt_edit_content_type (HEADER * h, BODY * b, FILE * fp)
     mutt_free_body (&b->parts);
   if (!mutt_is_message_type (b->type, b->subtype) && b->hdr) {
     b->hdr->content = NULL;
-    mutt_free_header (&b->hdr);
+    header_delete(&b->hdr);
   }
 
   if (fp && (is_multipart (b) || mutt_is_message_type (b->type, b->subtype)))
index 681ec86..b479dc2 100644 (file)
--- a/hcache.c
+++ b/hcache.c
@@ -565,7 +565,7 @@ static void *mutt_hcache_dump (void *_db, HEADER * h, int *off,
 HEADER *mutt_hcache_restore (const unsigned char *d, HEADER ** oh)
 {
   int off = 0;
-  HEADER *h = mutt_new_header ();
+  HEADER *h = header_new();
 
   /* skip validate */
   off += sizeof (validate);
@@ -576,7 +576,7 @@ HEADER *mutt_hcache_restore (const unsigned char *d, HEADER ** oh)
   memcpy (h, d + off, sizeof (HEADER));
   off += sizeof (HEADER);
 
-  h->env = mutt_new_envelope ();
+  h->env = envelope_new();
   restore_envelope (h->env, d, &off);
 
   h->content = mutt_new_body ();
@@ -588,7 +588,7 @@ HEADER *mutt_hcache_restore (const unsigned char *d, HEADER ** oh)
   if (oh) {
     h->old = (*oh)->old;
     h->path = m_strdup((*oh)->path);
-    mutt_free_header (oh);
+    header_delete(oh);
   }
 
   return h;
index 3ffd819..e4709ac 100644 (file)
--- a/headers.c
+++ b/headers.c
@@ -103,7 +103,7 @@ void mutt_edit_headers (const char *editor,
   n->references = msg->env->references;
   msg->env->references = NULL;
 
-  mutt_free_envelope (&msg->env);
+  envelope_delete(&msg->env);
   msg->env = n;
   n = NULL;
 
index 3ece306..518718f 100644 (file)
@@ -247,7 +247,7 @@ int imap_read_headers (IMAP_DATA * idata, int msgbegin, int msgend)
       fputs ("\n\n", fp);
 
       /* update context with message header */
-      ctx->hdrs[msgno] = mutt_new_header ();
+      ctx->hdrs[msgno] = header_new();
 
       ctx->hdrs[msgno]->index = h.sid - 1;
       if (h.sid != ctx->msgcount + 1)
index 9d4d70e..474a223 100644 (file)
@@ -99,6 +99,13 @@ typedef struct parameter {
     struct parameter *next;
 } PARAMETER;
 
+DO_INIT(PARAMETER, parameter);
+void parameter_wipe(PARAMETER *);
+
+DO_NEW(PARAMETER, parameter);
+DO_DELETE(PARAMETER, parameter);
+DO_SLIST(PARAMETER, parameter);
+
 
 /****************************************************************************/
 /* rfc822 envelopes                                                         */
@@ -135,6 +142,11 @@ typedef struct envelope_t {
     unsigned int refs_changed:1;  /* References changed to break thread */
 } ENVELOPE;
 
+DO_INIT(ENVELOPE, envelope);
+void envelope_wipe(ENVELOPE*);
+
+DO_NEW(ENVELOPE, envelope);
+DO_DELETE(ENVELOPE, envelope);
 
 /****************************************************************************/
 /* rfc822 content-*                                                         */
@@ -313,4 +325,10 @@ see: crypt.h pgplib.h, smime.h */
     char *maildir_flags;          /* unknown maildir flags */
 } HEADER;
 
+DO_INIT(HEADER, header);
+void header_wipe(HEADER *);
+
+DO_NEW(HEADER, header);
+DO_DELETE(HEADER, header);
+
 #endif /* MUTT_LIB_MIME_MIME_TYPES_H */
index 5eaab58..238bdbb 100644 (file)
@@ -17,6 +17,8 @@
  *  Copyright © 2006 Pierre Habouzit
  */
 
+#include "mime-types.h"
+
 const char MimeSpecials[] = "@.,;:<>[]\\\"()?/= \t";
 
 const char *BodyTypes[] = {
@@ -41,3 +43,62 @@ const char *BodyEncodings[] = {
     "x-uuencoded",
 };
 
+void address_wipe(address_t *addr)
+{
+    p_delete(&addr->personal);
+    p_delete(&addr->mailbox);
+    address_delete(&addr->next);
+}
+
+void parameter_wipe(PARAMETER *param)
+{
+    p_delete(&param->attribute);
+    p_delete(&param->value);
+    parameter_delete(&param->next);
+}
+
+void envelope_wipe(ENVELOPE *p)
+{
+    address_delete(&p->return_path);
+    address_delete(&p->from);
+    address_delete(&p->to);
+    address_delete(&p->cc);
+    address_delete(&p->bcc);
+    address_delete(&p->sender);
+    address_delete(&p->reply_to);
+    address_delete(&p->mail_followup_to);
+
+    p_delete(&p->list_post);
+    p_delete(&p->subject);
+    /* real_subj is just an offset to subject and shouldn't be freed */
+    p_delete(&p->message_id);
+    p_delete(&p->supersedes);
+    p_delete(&p->date);
+    p_delete(&p->x_label);
+    p_delete(&p->organization);
+#ifdef USE_NNTP
+    p_delete(&p->newsgroups);
+    p_delete(&p->xref);
+    p_delete(&p->followup_to);
+    p_delete(&p->x_comment_to);
+#endif
+
+    mutt_buffer_free (&p->spam);
+    mutt_free_list(&p->references);
+    mutt_free_list(&p->in_reply_to);
+    mutt_free_list(&p->userhdrs);
+}
+
+void header_wipe(HEADER *h)
+{
+    envelope_delete(&h->env);
+    mutt_free_body (&h->content);
+    p_delete(&h->maildir_flags);
+    p_delete(&h->tree);
+    p_delete(&h->path);
+#ifdef MIXMASTER
+    mutt_free_list(&h->chain);
+#endif
+    p_delete(&h->data);
+}
+
index 096c321..121dc6b 100644 (file)
@@ -56,7 +56,8 @@ extern const char *BodyEncodings[];
 extern const char RFC822Specials[];
 
 ssize_t mutt_read_rfc822_line(FILE*, char**, ssize_t*);
-LIST *mutt_parse_references (char *, int);
+LIST *mutt_parse_references(char *, int);
+int mutt_check_encoding(const char *);
 
 /*** addresses ***/
 
index 1d53c8e..ff6a02c 100644 (file)
@@ -141,7 +141,7 @@ static void purge_empty_parameters(PARAMETER **headp)
         if (!p->attribute || !p->value) {
             *headp = p->next;
             p->next = NULL;
-            mutt_free_parameter(&p);
+            parameter_delete(&p);
         } else {
             headp = &(*headp)->next;
         }
@@ -193,7 +193,7 @@ rfc2231_join_continuations(PARAMETER **head, rfc2231_param *par)
         if (value) {
             if (encoded)
                 mutt_convert_string (&value, charset, Charset, M_ICONV_HOOK_FROM);
-            *head = mutt_new_parameter ();
+            *head = parameter_new();
             (*head)->attribute = m_strdup(attribute);
             (*head)->value = value;
             head = &(*head)->next;
@@ -220,9 +220,7 @@ void rfc2231_decode_parameters (PARAMETER ** headp)
 
     int encoded;
     int idx;
-    short dirty = 0;              /* set to 1 when we may have created
-                                   * empty parameters.
-                                   */
+    short dirty = 0;   /* 1 when we may have created empty parameters. */
 
     if (!headp)
         return;
index 9009d40..6a2e0ee 100644 (file)
 
 #include "mutt_idna.h"
 
-void address_wipe(address_t *addr)
-{
-    p_delete(&addr->personal);
-    p_delete(&addr->mailbox);
-    address_delete(&addr->next);
-}
-
-
 void rfc822_qualify(address_t *addr, const char *host)
 {
     char *p;
index adc73d9..fb498b7 100644 (file)
@@ -163,27 +163,24 @@ LIST *mutt_parse_references(char *s, int in_reply_to)
     return lst;
 }
 
-int mutt_check_encoding (const char *c)
+int mutt_check_encoding(const char *s)
 {
-  if (ascii_strncasecmp ("7bit", c, sizeof ("7bit") - 1) == 0)
-    return (ENC7BIT);
-  else if (ascii_strncasecmp ("8bit", c, sizeof ("8bit") - 1) == 0)
-    return (ENC8BIT);
-  else if (ascii_strncasecmp ("binary", c, sizeof ("binary") - 1) == 0)
-    return (ENCBINARY);
-  else
-    if (ascii_strncasecmp
-        ("quoted-printable", c, sizeof ("quoted-printable") - 1) == 0)
-    return (ENCQUOTEDPRINTABLE);
-  else if (ascii_strncasecmp ("base64", c, sizeof ("base64") - 1) == 0)
-    return (ENCBASE64);
-  else if (ascii_strncasecmp ("x-uuencode", c, sizeof ("x-uuencode") - 1) == 0)
-    return (ENCUUENCODED);
-  else
-    return (ENCOTHER);
+#define COMPARE(tok, value)                             \
+    if (!ascii_strncasecmp(tok, s, sizeof(tok) - 1)) {  \
+        return value;                                   \
+    }
+    COMPARE("7bit", ENC7BIT);
+    COMPARE("8bit", ENC8BIT);
+    COMPARE("binary", ENCBINARY);
+    COMPARE("quoted-printable", ENCQUOTEDPRINTABLE);
+    COMPARE("base64", ENCBASE64);
+    COMPARE("x-uuencode", ENCUUENCODED);
+#undef COMPARE
+
+    return ENCOTHER;
 }
 
-static PARAMETER *parse_parameters (const char *s)
+static PARAMETER *parse_parameters(const char *s)
 {
   PARAMETER *head = 0, *cur = 0, *new;
   char buffer[LONG_STRING];
@@ -202,7 +199,7 @@ static PARAMETER *parse_parameters (const char *s)
     if (*p != ';') {
       i = p - s;
 
-      new = mutt_new_parameter ();
+      new = parameter_new();
 
       new->attribute = p_dupstr(s, i);
 
@@ -316,7 +313,7 @@ void mutt_parse_content_type (char *s, BODY * ct)
   char *subtype;
 
   p_delete(&ct->subtype);
-  mutt_free_parameter (&ct->parameter);
+  parameter_delete(&ct->parameter);
 
   /* First extract any existing parameters */
   if ((pc = strchr (s, ';')) != NULL) {
@@ -399,7 +396,7 @@ static void parse_content_disposition (char *s, BODY * ct)
       m_strreplace(&ct->filename, s);
     if ((s = mutt_get_parameter ("name", parms)) != 0)
       ct->form_name = m_strdup(s);
-    mutt_free_parameter (&parms);
+    parameter_delete(&parms);
   }
 }
 
@@ -514,7 +511,7 @@ BODY *mutt_parse_messageRFC822 (FILE * fp, BODY * parent)
 {
   BODY *msg;
 
-  parent->hdr = mutt_new_header ();
+  parent->hdr = header_new();
   parent->hdr->offset = ftello (fp);
   parent->hdr->env = mutt_read_rfc822_header (fp, parent->hdr, 0, 0);
   msg = parent->hdr->content;
@@ -1249,12 +1246,12 @@ done:
  *             Used for recall-message.
  *
  * Returns:     newly allocated envelope structure.  You should free it by
- *              mutt_free_envelope() when envelope stay unneeded.
+ *              envelope_delete() when envelope stay unneeded.
  */
 ENVELOPE *mutt_read_rfc822_header (FILE * f, HEADER * hdr, short user_hdrs,
                                    short weed)
 {
-  ENVELOPE *e = mutt_new_envelope ();
+  ENVELOPE *e = envelope_new();
   LIST *last = NULL;
   char *line = p_new(char, LONG_STRING);
   char *p;
diff --git a/main.c b/main.c
index 56030ee..e8f4ef3 100644 (file)
--- a/main.c
+++ b/main.c
@@ -588,9 +588,9 @@ int main (int argc, char **argv)
     case 'b':
     case 'c':
       if (!msg)
-        msg = mutt_new_header ();
+        msg = header_new();
       if (!msg->env)
-        msg->env = mutt_new_envelope ();
+        msg->env = envelope_new();
       if (i == 'b')
         msg->env->bcc = rfc822_parse_adrlist (msg->env->bcc, optarg);
       else
@@ -793,13 +793,13 @@ int main (int argc, char **argv)
       mutt_flushinp ();
 
     if (!msg)
-      msg = mutt_new_header ();
+      msg = header_new();
 
     if (draftFile)
       infile = draftFile;
     else {
       if (!msg->env)
-        msg->env = mutt_new_envelope ();
+        msg->env = envelope_new();
 
       for (i = optind; i < argc; i++) {
         if (url_check_scheme (argv[i]) == U_MAILTO)
diff --git a/mbox.c b/mbox.c
index c3dc0fd..e140ee4 100644 (file)
--- a/mbox.c
+++ b/mbox.c
@@ -125,7 +125,7 @@ static int mmdf_parse_mailbox (CONTEXT * ctx)
 
       if (ctx->msgcount == ctx->hdrmax)
         mx_alloc_memory (ctx);
-      ctx->hdrs[ctx->msgcount] = hdr = mutt_new_header ();
+      ctx->hdrs[ctx->msgcount] = hdr = header_new();
       hdr->offset = loc;
       hdr->index = ctx->msgcount;
 
@@ -262,7 +262,7 @@ static int mbox_parse_mailbox (CONTEXT * ctx)
       if (ctx->msgcount == ctx->hdrmax)
         mx_alloc_memory (ctx);
 
-      curhdr = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
+      curhdr = ctx->hdrs[ctx->msgcount] = header_new();
       curhdr->received = t - tz;
       curhdr->offset = loc;
       curhdr->index = ctx->msgcount;
@@ -906,7 +906,7 @@ static int mbox_reopen_mailbox (CONTEXT * ctx, int *index_hint)
   p_delete(&ctx->v2r);
   if (ctx->readonly) {
     for (i = 0; i < ctx->msgcount; i++)
-      mutt_free_header (&(ctx->hdrs[i]));       /* nothing to do! */
+      header_delete(&(ctx->hdrs[i]));       /* nothing to do! */
     p_delete(&ctx->hdrs);
   }
   else {
@@ -952,7 +952,7 @@ static int mbox_reopen_mailbox (CONTEXT * ctx, int *index_hint)
   if (rc == -1) {
     /* free the old headers */
     for (j = 0; j < old_msgcount; j++)
-      mutt_free_header (&(old_hdrs[j]));
+      header_delete(&(old_hdrs[j]));
     p_delete(&old_hdrs);
 
     ctx->quiet = 0;
@@ -1010,14 +1010,14 @@ static int mbox_reopen_mailbox (CONTEXT * ctx, int *index_hint)
         mutt_set_flag (ctx, ctx->hdrs[i], M_TAG, old_hdrs[j]->tagged);
 
         /* we don't need this header any more */
-        mutt_free_header (&(old_hdrs[j]));
+        header_delete(&(old_hdrs[j]));
       }
     }
 
     /* free the remaining old headers */
     for (j = 0; j < old_msgcount; j++) {
       if (old_hdrs[j]) {
-        mutt_free_header (&(old_hdrs[j]));
+        header_delete(&(old_hdrs[j]));
         msg_mod = 1;
       }
     }
diff --git a/mh.c b/mh.c
index 63c7bd7..d55115d 100644 (file)
--- a/mh.c
+++ b/mh.c
@@ -463,7 +463,7 @@ static void maildir_free_entry (struct maildir **md)
 
   p_delete(&(*md)->canon_fname);
   if ((*md)->h)
-    mutt_free_header (&(*md)->h);
+    header_delete(&(*md)->h);
 
   p_delete(md);
 }
@@ -567,7 +567,7 @@ static HEADER *maildir_parse_message (int magic, const char *fname,
 
   if ((f = fopen (fname, "r")) != NULL) {
     if (!h)
-      h = mutt_new_header ();
+      h = header_new();
     h->env = mutt_read_rfc822_header (f, h, 0, 0);
 
     fstat (fileno (f), &st);
@@ -624,7 +624,7 @@ static int maildir_parse_entry (CONTEXT * ctx, struct maildir ***last,
   if (ctx->magic == M_MH)
     h = maildir_parse_message (ctx->magic, buf, is_old, NULL);
   else {
-    h = mutt_new_header ();
+    h = header_new();
     h->old = is_old;
     maildir_parse_flags (h, buf);
   }
@@ -819,7 +819,7 @@ void maildir_delayed_parsing (CONTEXT * ctx, struct maildir *md)
 #endif
     }
     else
-      mutt_free_header (&p->h);
+      header_delete(&p->h);
 #ifdef USE_HCACHE
     p_delete(&data);
 #endif
@@ -1555,7 +1555,7 @@ static int maildir_check_mailbox (CONTEXT * ctx, int *index_hint, int unused)
       ctx->hdrs[i]->trash = p->h->trash;
 
       /* this is a duplicate of an existing header, so remove it */
-      mutt_free_header (&p->h);
+      header_delete(&p->h);
     }
     /* This message was not in the list of messages we just scanned.
      * Check to see if we have enough information to know if the
@@ -1674,7 +1674,7 @@ static int mh_check_mailbox (CONTEXT * ctx, int *index_hint, int unused)
       if (!ctx->hdrs[i]->changed)
         maildir_update_flags (ctx, ctx->hdrs[i], p->h);
 
-      mutt_free_header (&p->h);
+      header_delete(&p->h);
     }
     else                        /* message has disappeared */
       occult = 1;
index e3a7cad..c5be0b7 100644 (file)
--- a/muttlib.c
+++ b/muttlib.c
@@ -155,7 +155,7 @@ int mutt_copy_body (FILE * fp, BODY ** tgt, BODY * src)
   /* copy parameters */
   for (par = b->parameter, ppar = &b->parameter; par;
        ppar = &(*ppar)->next, par = par->next) {
-    *ppar = mutt_new_parameter ();
+    *ppar = parameter_new();
     (*ppar)->attribute = m_strdup(par->attribute);
     (*ppar)->value = m_strdup(par->value);
   }
@@ -176,7 +176,7 @@ void mutt_free_body (BODY ** p)
     a = a->next;
 
     if (b->parameter)
-      mutt_free_parameter (&b->parameter);
+      parameter_delete(&b->parameter);
     if (b->unlink && b->filename) {
       debug_print (1, ("unlinking %s.\n", b->filename));
       unlink (b->filename);
@@ -194,7 +194,7 @@ void mutt_free_body (BODY ** p)
     if (b->hdr) {
       /* Don't free twice (b->hdr->content = b->parts) */
       b->hdr->content = NULL;
-      mutt_free_header (&b->hdr);
+      header_delete(&b->hdr);
     }
 
     if (b->parts)
@@ -206,46 +206,15 @@ void mutt_free_body (BODY ** p)
   *p = 0;
 }
 
-void mutt_free_parameter (PARAMETER ** p)
-{
-  PARAMETER *t = *p;
-  PARAMETER *o;
-
-  while (t) {
-    p_delete(&t->attribute);
-    p_delete(&t->value);
-    o = t;
-    t = t->next;
-    p_delete(&o);
-  }
-  *p = 0;
-}
-
 HEADER *mutt_dup_header (HEADER * h)
 {
   HEADER *hnew;
 
-  hnew = mutt_new_header ();
+  hnew = header_new();
   memcpy (hnew, h, sizeof (HEADER));
   return hnew;
 }
 
-void mutt_free_header (HEADER ** h)
-{
-  if (!h || !*h)
-    return;
-  mutt_free_envelope (&(*h)->env);
-  mutt_free_body (&(*h)->content);
-  p_delete(&(*h)->maildir_flags);
-  p_delete(&(*h)->tree);
-  p_delete(&(*h)->path);
-#ifdef MIXMASTER
-  mutt_free_list (&(*h)->chain);
-#endif
-  p_delete(&(*h)->data);
-  p_delete(h);
-}
-
 /* returns true if the header contained in "s" is in list "t" */
 int mutt_matches_ignore (const char *s, LIST * t)
 {
@@ -354,12 +323,12 @@ char *_mutt_expand_path (char *s, size_t slen, int rx)
         address_t *alias;
 
         if ((alias = mutt_lookup_alias (s + 1))) {
-          h = mutt_new_header ();
-          h->env = mutt_new_envelope ();
+          h = header_new();
+          h->env = envelope_new();
           h->env->from = h->env->to = alias;
           mutt_default_save (p, sizeof (p), h);
           h->env->from = h->env->to = NULL;
-          mutt_free_header (&h);
+          header_delete(&h);
           /* Avoid infinite recursion if the resulting folder starts with '@' */
           if (*p != '@')
             recurse = 1;
@@ -502,7 +471,7 @@ void mutt_set_parameter (const char *attribute, const char *value,
     }
   }
 
-  q = mutt_new_parameter ();
+  q = parameter_new();
   q->attribute = m_strdup(attribute);
   q->value = m_strdup(value);
   q->next = *p;
@@ -517,7 +486,7 @@ void mutt_delete_parameter (const char *attribute, PARAMETER ** p)
     if (ascii_strcasecmp (attribute, q->attribute) == 0) {
       *p = q->next;
       q->next = NULL;
-      mutt_free_parameter (&q);
+      parameter_delete(&q);
       return;
     }
   }
@@ -574,46 +543,11 @@ int mutt_is_text_part (BODY * b)
   return 0;
 }
 
-void mutt_free_envelope (ENVELOPE ** p)
-{
-  if (!*p)
-    return;
-  address_delete (&(*p)->return_path);
-  address_delete (&(*p)->from);
-  address_delete (&(*p)->to);
-  address_delete (&(*p)->cc);
-  address_delete (&(*p)->bcc);
-  address_delete (&(*p)->sender);
-  address_delete (&(*p)->reply_to);
-  address_delete (&(*p)->mail_followup_to);
-
-  p_delete(&(*p)->list_post);
-  p_delete(&(*p)->subject);
-  /* real_subj is just an offset to subject and shouldn't be freed */
-  p_delete(&(*p)->message_id);
-  p_delete(&(*p)->supersedes);
-  p_delete(&(*p)->date);
-  p_delete(&(*p)->x_label);
-  p_delete(&(*p)->organization);
-#ifdef USE_NNTP
-  p_delete(&(*p)->newsgroups);
-  p_delete(&(*p)->xref);
-  p_delete(&(*p)->followup_to);
-  p_delete(&(*p)->x_comment_to);
-#endif
-
-  mutt_buffer_free (&(*p)->spam);
-  mutt_free_list (&(*p)->references);
-  mutt_free_list (&(*p)->in_reply_to);
-  mutt_free_list (&(*p)->userhdrs);
-  p_delete(p);
-}
-
 /* move all the headers from extra not present in base into base */
 void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra)
 {
   /* copies each existing element if necessary, and sets the element
-  * to NULL in the source so that mutt_free_envelope doesn't leave us
+  * to NULL in the source so that envelope_delete doesn't leave us
   * with dangling pointers. */
 #define MOVE_ELEM(h) if (!base->h) { base->h = (*extra)->h; (*extra)->h = NULL; }
   MOVE_ELEM(return_path);
@@ -650,7 +584,7 @@ void mutt_merge_envelopes(ENVELOPE* base, ENVELOPE** extra)
   MOVE_ELEM(userhdrs);
 #undef MOVE_ELEM
   
-  mutt_free_envelope(extra);
+  envelope_delete(extra);
 }
 
 void _mutt_mktemp (char *s, const char *src, int line)
diff --git a/mx.c b/mx.c
index b1efdce..5b48ab8 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -592,7 +592,7 @@ void mx_fastclose_mailbox (CONTEXT * ctx)
     hash_destroy (&ctx->id_hash, NULL);
   mutt_clear_threads (ctx);
   for (i = 0; i < ctx->msgcount; i++)
-    mutt_free_header (&ctx->hdrs[i]);
+    header_delete(&ctx->hdrs[i]);
   p_delete(&ctx->hdrs);
   p_delete(&ctx->v2r);
 
@@ -947,7 +947,7 @@ void mx_update_tables (CONTEXT * ctx, int committing)
       if (ctx->id_hash && ctx->hdrs[i]->env->message_id)
         hash_delete (ctx->id_hash, ctx->hdrs[i]->env->message_id,
                      ctx->hdrs[i], NULL);
-      mutt_free_header (&ctx->hdrs[i]);
+      header_delete(&ctx->hdrs[i]);
     }
   }
 #undef this_body
index 0c7af82..c9b1a02 100644 (file)
@@ -555,7 +555,7 @@ static int nntp_parse_xover (CONTEXT * ctx, char *buf, HEADER * hdr)
   char *p, *b;
   int x, done = 0;
 
-  hdr->env = mutt_new_envelope ();
+  hdr->env = envelope_new();
   hdr->env->newsgroups = m_strdup(nntp_data->group);
   hdr->content = mutt_new_body ();
   hdr->content->type = TYPETEXT;
@@ -666,7 +666,7 @@ static int add_xover_line (char *line, void *c)
 
   if (ctx->msgcount >= ctx->hdrmax)
     mx_alloc_memory (ctx);
-  ctx->hdrs[ctx->msgcount] = mutt_new_header ();
+  ctx->hdrs[ctx->msgcount] = header_new();
   ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
 
   nntp_parse_xover (ctx, line, ctx->hdrs[ctx->msgcount]);
@@ -682,7 +682,7 @@ static int add_xover_line (char *line, void *c)
       mutt_message ("%s %d/%d", fc->msg, num, total);
   }
   else
-    mutt_free_header (&ctx->hdrs[ctx->msgcount]);       /* skip it */
+    header_delete(&ctx->hdrs[ctx->msgcount]);       /* skip it */
 
   return 0;
 }
@@ -811,7 +811,7 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first,
 
       if (ctx->msgcount >= ctx->hdrmax)
         mx_alloc_memory (ctx);
-      h = ctx->hdrs[ctx->msgcount] = mutt_new_header ();
+      h = ctx->hdrs[ctx->msgcount] = header_new();
       h->index = ctx->msgcount;
 
       ret = nntp_read_header (ctx, NULL, current);
@@ -821,7 +821,7 @@ static int nntp_fetch_headers (CONTEXT * ctx, unsigned int first,
         mx_update_context (ctx, 1);
       }
       else
-        mutt_free_header (&h);  /* skip it */
+        header_delete(&h);  /* skip it */
       if (ret == -1) {
         p_delete(&fc.messages);
         return -1;
@@ -989,7 +989,7 @@ int nntp_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
     return -1;
   }
 
-  mutt_free_envelope (&ctx->hdrs[msgno]->env);
+  envelope_delete(&ctx->hdrs[msgno]->env);
   ctx->hdrs[msgno]->env =
     mutt_read_rfc822_header (msg->fp, ctx->hdrs[msgno], 0, 0);
   /* fix content length */
@@ -1463,7 +1463,7 @@ int nntp_check_msgid (CONTEXT * ctx, const char *msgid)
     return 1;
   if (ctx->msgcount == ctx->hdrmax)
     mx_alloc_memory (ctx);
-  ctx->hdrs[ctx->msgcount] = mutt_new_header ();
+  ctx->hdrs[ctx->msgcount] = header_new();
   ctx->hdrs[ctx->msgcount]->index = ctx->msgcount;
 
   mutt_message (_("Fetching %s from server..."), msgid);
@@ -1471,7 +1471,7 @@ int nntp_check_msgid (CONTEXT * ctx, const char *msgid)
   /* since nntp_read_header() may set read flag, we must reset it */
   ctx->hdrs[ctx->msgcount]->read = 0;
   if (ret != 0)
-    mutt_free_header (&ctx->hdrs[ctx->msgcount]);
+    header_delete(&ctx->hdrs[ctx->msgcount]);
   else {
     ctx->msgcount++;
     mx_update_context (ctx, 1);
index 904f122..2e87631 100644 (file)
--- a/pop/pop.c
+++ b/pop/pop.c
@@ -142,7 +142,7 @@ static int fetch_uidl (char *line, void *data)
       mx_alloc_memory (ctx);
 
     ctx->msgcount++;
-    ctx->hdrs[i] = mutt_new_header ();
+    ctx->hdrs[i] = header_new();
     ctx->hdrs[i]->data = m_strdup(line);
   }
   else if (ctx->hdrs[i]->index != index - 1)
@@ -217,7 +217,7 @@ static int pop_fetch_headers (CONTEXT * ctx)
 
   if (ret != PQ_OK) {
     for (i = ctx->msgcount; i < new_count; i++)
-      mutt_free_header (&ctx->hdrs[i]);
+      header_delete(&ctx->hdrs[i]);
     return ret;
   }
 
@@ -409,7 +409,7 @@ int pop_fetch_message (MESSAGE * msg, CONTEXT * ctx, int msgno)
   cache->path = m_strdup(path);
   rewind (msg->fp);
   uidl = h->data;
-  mutt_free_envelope (&h->env);
+  envelope_delete(&h->env);
   h->env = mutt_read_rfc822_header (msg->fp, h, 0, 0);
   h->data = uidl;
   h->lines = 0;
index e73b39b..c503543 100644 (file)
@@ -541,7 +541,7 @@ int mutt_prepare_template (FILE * fp, CONTEXT * ctx, HEADER * newhdr,
         || b == NULL) {
     err:
       mx_close_message (&msg);
-      mutt_free_envelope (&newhdr->env);
+      envelope_delete(&newhdr->env);
       mutt_free_body (&newhdr->content);
       mutt_error _("Decryption failed.");
 
@@ -679,7 +679,7 @@ bail:
     mx_close_message (&msg);
 
   if (rv == -1) {
-    mutt_free_envelope (&newhdr->env);
+    envelope_delete(&newhdr->env);
     mutt_free_body (&newhdr->content);
   }
 
index 0daa2ac..b499e83 100644 (file)
--- a/protos.h
+++ b/protos.h
@@ -31,9 +31,6 @@ void _mutt_make_string (char *, size_t, const char *, CONTEXT *,
 #define mutt_system(x) _mutt_system(x,0)
 int _mutt_system (const char *, int);
 
-#define mutt_new_parameter() p_new(PARAMETER, 1)
-#define mutt_new_header() p_new(HEADER, 1)
-#define mutt_new_envelope() p_new(ENVELOPE, 1)
 #define mutt_new_enter_state() p_new(ENTER_STATE, 1)
 
 typedef const char *format_t (char *, size_t, char, const char *,
@@ -63,7 +60,7 @@ 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);
+BODY *mutt_new_body(void);
 BODY *mutt_parse_multipart (FILE *, const char *, off_t, int);
 BODY *mutt_parse_messageRFC822 (FILE *, BODY *);
 BODY *mutt_read_mime_header (FILE *, int);
@@ -138,9 +135,6 @@ 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_free_envelope (ENVELOPE **);
-void mutt_free_header (HEADER **);
-void mutt_free_parameter (PARAMETER **);
 void mutt_generate_header (char *, size_t, HEADER *, int);
 void mutt_help (int);
 void mutt_draw_tree (CONTEXT *);
@@ -200,7 +194,6 @@ int mutt_alloc_color (int fg, int bg);
 int mutt_any_key_to_continue (const char *);
 int mutt_can_decode (BODY *);
 int mutt_change_flag (HEADER *, int);
-int mutt_check_encoding (const char *);
 int mutt_check_key (const char *);
 int mutt_check_menu (const char *);
 int mutt_check_mime_type (const char *);
diff --git a/query.c b/query.c
index 398f3b4..0b72303 100644 (file)
--- a/query.c
+++ b/query.c
@@ -401,8 +401,8 @@ static void query_menu (char *buf, size_t buflen, QUERY * results, int retbuf)
         /* fall through to OP_MAIL */
 
       case OP_MAIL:
-        msg = mutt_new_header ();
-        msg->env = mutt_new_envelope ();
+        msg = header_new();
+        msg->env = envelope_new();
         if (!menu->tagprefix) {
           msg->env->to = result_to_addr (QueryTable[menu->current].data);
         }
index c051b8a..3ea0363 100644 (file)
--- a/recvcmd.c
+++ b/recvcmd.c
@@ -388,8 +388,8 @@ static void attach_forward_bodies (FILE * fp, HEADER * hdr,
     parent = hdr;
 
 
-  tmphdr = mutt_new_header ();
-  tmphdr->env = mutt_new_envelope ();
+  tmphdr = header_new();
+  tmphdr->env = envelope_new();
   mutt_make_forward_subject (tmphdr->env, Context, parent);
 
   mutt_mktemp (tmpbody);
@@ -507,7 +507,7 @@ bail:
     mutt_unlink (tmpbody);
   }
 
-  mutt_free_header (&tmphdr);
+  header_delete(&tmphdr);
 }
 
 
@@ -548,8 +548,8 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr,
       }
   }
 
-  tmphdr = mutt_new_header ();
-  tmphdr->env = mutt_new_envelope ();
+  tmphdr = header_new();
+  tmphdr->env = envelope_new();
   mutt_make_forward_subject (tmphdr->env, Context, curhdr);
 
 
@@ -563,7 +563,7 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr,
     mutt_mktemp (tmpbody);
     if (!(tmpfp = safe_fopen (tmpbody, "w"))) {
       mutt_error (_("Can't create %s."), tmpbody);
-      mutt_free_header (&tmphdr);
+      header_delete(&tmphdr);
       return;
     }
 
@@ -615,7 +615,7 @@ static void attach_forward_msgs (FILE * fp, HEADER * hdr,
     }
   }
   else
-    mutt_free_header (&tmphdr);
+    header_delete(&tmphdr);
 
   ci_send_message (flags, tmphdr, *tmpbody ? tmpbody : NULL, NULL, curhdr);
 
@@ -800,21 +800,21 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr,
   else if (nattach == 1)
     mime_reply_any = 1;
 
-  tmphdr = mutt_new_header ();
-  tmphdr->env = mutt_new_envelope ();
+  tmphdr = header_new();
+  tmphdr->env = envelope_new();
 
   if (attach_reply_envelope_defaults (tmphdr->env, idx, idxlen,
                                       parent ? parent : (cur ? cur->
                                                          hdr : NULL),
                                       flags) == -1) {
-    mutt_free_header (&tmphdr);
+    header_delete(&tmphdr);
     return;
   }
 
   mutt_mktemp (tmpbody);
   if ((tmpfp = safe_fopen (tmpbody, "w")) == NULL) {
     mutt_error (_("Can't create %s."), tmpbody);
-    mutt_free_header (&tmphdr);
+    header_delete(&tmphdr);
     return;
   }
 
@@ -872,7 +872,7 @@ void mutt_attach_reply (FILE * fp, HEADER * hdr,
     if (mime_reply_any && !cur &&
         copy_problematic_attachments (fp, &tmphdr->content, idx, idxlen,
                                       0) == NULL) {
-      mutt_free_header (&tmphdr);
+      header_delete(&tmphdr);
       fclose (tmpfp);
       return;
     }
diff --git a/send.c b/send.c
index 82fd71a..a582451 100644 (file)
--- a/send.c
+++ b/send.c
@@ -1072,7 +1072,7 @@ static void fix_end_of_file (const char *data)
 
 int mutt_resend_message (FILE * fp, CONTEXT * ctx, HEADER * cur)
 {
-  HEADER *msg = mutt_new_header ();
+  HEADER *msg = header_new();
 
   if (mutt_prepare_template (fp, ctx, msg, cur, 1) < 0)
     return -1;
@@ -1135,7 +1135,7 @@ int ci_send_message (int flags, /* send mode */
    */
 
   if (!msg) {
-    msg = mutt_new_header ();
+    msg = header_new();
 
     if (flags == SENDPOSTPONED) {
       if ((flags =
@@ -1165,7 +1165,7 @@ int ci_send_message (int flags, /* send mode */
     }
 
     if (!msg->env)
-      msg->env = mutt_new_envelope ();
+      msg->env = envelope_new();
   }
 
   /* Parse and use an eventual list-post header */
@@ -1811,7 +1811,7 @@ cleanup:
   }
 
   safe_fclose (&tempfp);
-  mutt_free_header (&msg);
+  header_delete(&msg);
 
   return rv;
 }
index 03dd11a..02d0ee0 100644 (file)
--- a/sendlib.c
+++ b/sendlib.c
@@ -1231,7 +1231,7 @@ BODY *mutt_make_message_attach (CONTEXT * ctx, HEADER * hdr, int attach_msg)
   fflush (fp);
   rewind (fp);
 
-  body->hdr = mutt_new_header ();
+  body->hdr = header_new();
   body->hdr->offset = 0;
   /* we don't need the user headers here */
   body->hdr->env = mutt_read_rfc822_header (fp, body->hdr, 0, 0);