From: Thomas Roessler Date: Thu, 15 Oct 1998 01:17:41 +0000 (+0000) Subject: Fixing a memory hog which was introduced by the edit-message patch. X-Git-Tag: mutt-0-94-13-rel~9 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a9ea1add36030ef996c8f434a2baadb32ed4357d;p=mutt Fixing a memory hog which was introduced by the edit-message patch. --- diff --git a/buffy.c b/buffy.c index a90730a7..512d70b0 100644 --- a/buffy.c +++ b/buffy.c @@ -97,7 +97,7 @@ int test_last_status_new (FILE * f) return (0); hdr = mutt_new_header (); - mutt_read_rfc822_header (f, hdr); + mutt_read_rfc822_header (f, hdr, 0); if (!(hdr->read || hdr->old)) result = 1; mutt_free_header (&hdr); diff --git a/headers.c b/headers.c index e4ea13da..e92ba340 100644 --- a/headers.c +++ b/headers.c @@ -129,7 +129,7 @@ void mutt_edit_headers (const char *editor, /* Read the temp file back in */ ifp = fopen (path, "r"); ofp = safe_fopen (body, "w"); - n = mutt_read_rfc822_header (ifp, NULL); + n = mutt_read_rfc822_header (ifp, NULL, 1); while ((i = fread (buffer, 1, sizeof (buffer), ifp)) > 0) fwrite (buffer, 1, i, ofp); fclose (ofp); diff --git a/imap.c b/imap.c index 34e59061..5e4514bb 100644 --- a/imap.c +++ b/imap.c @@ -531,7 +531,7 @@ static int imap_read_headers (CONTEXT *ctx, int msgbegin, int msgend) ctx->hdrs[ctx->msgcount] = mutt_new_header (); ctx->hdrs[ctx->msgcount]->index = ctx->msgcount; - ctx->hdrs[msgno]->env = mutt_read_rfc822_header (fp, ctx->hdrs[msgno]); + ctx->hdrs[msgno]->env = mutt_read_rfc822_header (fp, ctx->hdrs[msgno], 0); ploc=ftell(fp); ctx->hdrs[msgno]->read = h->read; ctx->hdrs[msgno]->old = h->old; diff --git a/main.c b/main.c index 249dbc6d..a0041790 100644 --- a/main.c +++ b/main.c @@ -568,7 +568,7 @@ int main (int argc, char **argv) tempfile = safe_strdup (buf); if (draftFile) - msg->env = mutt_read_rfc822_header (fin, NULL); + msg->env = mutt_read_rfc822_header (fin, NULL, 1); if (tempfile) { diff --git a/mbox.c b/mbox.c index 54153eab..f644e7aa 100644 --- a/mbox.c +++ b/mbox.c @@ -135,7 +135,7 @@ int mmdf_parse_mailbox (CONTEXT *ctx) else hdr->received = t + tz; - hdr->env = mutt_read_rfc822_header (ctx->fp, hdr); + hdr->env = mutt_read_rfc822_header (ctx->fp, hdr, 0); loc = ftell (ctx->fp); @@ -270,7 +270,7 @@ int mbox_parse_mailbox (CONTEXT *ctx) curhdr->offset = loc; curhdr->index = ctx->msgcount; - curhdr->env = mutt_read_rfc822_header (ctx->fp, curhdr); + curhdr->env = mutt_read_rfc822_header (ctx->fp, curhdr, 0); /* if we know how long this message is, either just skip over the body, * or if we don't know how many lines there are, count them now (this will diff --git a/mh.c b/mh.c index 99f55ec3..c8b78435 100644 --- a/mh.c +++ b/mh.c @@ -132,7 +132,7 @@ static HEADER *maildir_parse_message(int magic, const char *fname, int is_old) if ((f = fopen (fname, "r")) != NULL) { h = mutt_new_header(); - h->env = mutt_read_rfc822_header (f, h); + h->env = mutt_read_rfc822_header (f, h, 0); fstat (fileno (f), &st); fclose (f); diff --git a/parse.c b/parse.c index b3558e93..64ed48ed 100644 --- a/parse.c +++ b/parse.c @@ -423,7 +423,7 @@ BODY *mutt_parse_messageRFC822 (FILE *fp, BODY *parent) parent->hdr = mutt_new_header (); parent->hdr->offset = ftell (fp); - parent->hdr->env = mutt_read_rfc822_header (fp, parent->hdr); + parent->hdr->env = mutt_read_rfc822_header (fp, parent->hdr, 0); msg = parent->hdr->content; /* ignore the length given in the content-length since it could be wrong @@ -835,12 +835,13 @@ void mutt_parse_mime_message (CONTEXT *ctx, HEADER *cur) * * f stream to read from * - * hdr header structure of current message (optional). If hdr is - * NULL, then we are reading a postponed message, or called - * from mutt_edit_headers() so we should keep a list of the - * user-defined headers. + * hdr header structure of current message (optional). + * + * user_hdrs If set, store user headers. Used for edit-message and + * postpone modes. + * */ -ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr) +ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr, short user_hdrs) { ENVELOPE *e = mutt_new_envelope(); LIST *last = NULL; @@ -1156,7 +1157,7 @@ ENVELOPE *mutt_read_rfc822_header (FILE *f, HEADER *hdr) } /* Keep track of the user-defined headers */ - if (!matched) + if (!matched && user_hdrs) { if (last) { diff --git a/parse.h b/parse.h index 78cfaeb9..7de66270 100644 --- a/parse.h +++ b/parse.h @@ -1,8 +1,11 @@ /* $Id$ */ + +/* XXX this file duplicates content from protos.h */ + BODY *mutt_parse_multipart (FILE *, const char *, long, int); BODY *mutt_parse_messageRFC822 (FILE *, BODY *); BODY *mutt_read_mime_header (FILE *, int); -ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *); +ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short); time_t is_from (const char *, char *, size_t); diff --git a/po/mutt.pot b/po/mutt.pot index 9d66e369..05042268 100644 --- a/po/mutt.pot +++ b/po/mutt.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 1998-10-15 00:54+0200\n" +"POT-Creation-Date: 1998-10-15 03:08+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -2760,17 +2760,17 @@ msgstr "" msgid "Could not open %s" msgstr "" -#: sendlib.c:1694 +#: sendlib.c:1695 #, c-format msgid "Error sending message, child exited %d (%s).\n" msgstr "" -#: sendlib.c:1696 +#: sendlib.c:1697 #, c-format msgid "Saved output of child process to %s.\n" msgstr "" -#: sendlib.c:1700 +#: sendlib.c:1701 msgid "Error sending message." msgstr "" diff --git a/postpone.c b/postpone.c index 23711555..02e18efd 100644 --- a/postpone.c +++ b/postpone.c @@ -380,7 +380,7 @@ int mutt_edit_message (CONTEXT *ctx, HEADER *newhdr, HEADER *hdr) return (-1); fseek (msg->fp, hdr->offset, 0); - newhdr->env = mutt_read_rfc822_header (msg->fp, newhdr); + newhdr->env = mutt_read_rfc822_header (msg->fp, newhdr, 1); if (hdr->content->type == TYPEMESSAGE || hdr->content->type == TYPEMULTIPART) { diff --git a/protos.h b/protos.h index db165612..e795b10a 100644 --- a/protos.h +++ b/protos.h @@ -87,7 +87,7 @@ BODY *mutt_parse_multipart (FILE *, const char *, long, int); BODY *mutt_parse_messageRFC822 (FILE *, BODY *); BODY *mutt_read_mime_header (FILE *, int); -ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *); +ENVELOPE *mutt_read_rfc822_header (FILE *, HEADER *, short); HEADER *mutt_dup_header (HEADER *); ATTACHPTR **mutt_gen_attach_list (BODY *, ATTACHPTR **, short *, short *, int, int); diff --git a/sendlib.c b/sendlib.c index 8bf1917f..ccd3444a 100644 --- a/sendlib.c +++ b/sendlib.c @@ -1024,7 +1024,8 @@ BODY *mutt_make_message_attach (CONTEXT *ctx, HEADER *hdr, int attach_msg) body->hdr = mutt_new_header(); body->hdr->offset = 0; - body->hdr->env = mutt_read_rfc822_header(fp, body->hdr); + /* we don't need the user headers here */ + body->hdr->env = mutt_read_rfc822_header(fp, body->hdr, 0); #ifdef _PGPPATH body->hdr->pgp = pgp; #endif /* _PGPPATH */