Now that every call to mx_open_mailbox let it allocate the context, the
pointer to a context parameter is not necessary, so it can be dropped.
---
attach.c | 2 +-
buffy.c | 3 +--
commands.c | 2 +-
compose.c | 4 ++--
curs_main.c | 7 ++++---
editmsg.c | 4 ++--
imap/imap.c | 2 +-
mailbox.h | 2 +-
main.c | 2 +-
mx.c | 20 +++++++-------------
pop.c | 2 +-
postpone.c | 4 ++--
sendlib.c | 2 +-
13 files changed, 25 insertions(+), 31 deletions(-)
diff --git a/attach.c b/attach.c
index bf935f5..a8290e3 100644
--- a/attach.c
+++ b/attach.c
@@ -729,7 +729,7 @@ int mutt_save_attachment (FILE *fp, BODY *m, char *path,
int flags, HEADER *hdr)
fseeko (fp, m->offset, 0);
if (fgets (buf, sizeof (buf), fp) == NULL)
return -1;
- ctx = mx_open_mailbox (path, MUTT_APPEND | MUTT_QUIET, NULL);
+ ctx = mx_open_mailbox (path, MUTT_APPEND | MUTT_QUIET);
if (ctx == NULL)
return -1;
if ((msg = mx_open_new_message (ctx, hn, is_from (buf, NULL, 0, NULL) ?
0 : MUTT_ADD_FROM)) == NULL)
diff --git a/buffy.c b/buffy.c
index 61e491f..87573f2 100644
--- a/buffy.c
+++ b/buffy.c
@@ -448,8 +448,7 @@ static int buffy_mbox_check (BUFFY* mailbox, struct stat
*sb, int check_stats)
{
CONTEXT *ctx = mx_open_mailbox (mailbox->path,
MUTT_READONLY | MUTT_QUIET |
- MUTT_NOSORT | MUTT_PEEK,
- NULL);
+ MUTT_NOSORT | MUTT_PEEK);
if (ctx)
{
mailbox->msg_count = ctx->msgcount;
diff --git a/commands.c b/commands.c
index d6474f9..d67d4d9 100644
--- a/commands.c
+++ b/commands.c
@@ -835,7 +835,7 @@ int mutt_save_message (HEADER *h, int delete,
}
#endif
- ctx = mx_open_mailbox (buf, MUTT_APPEND, NULL);
+ ctx = mx_open_mailbox (buf, MUTT_APPEND);
if (ctx)
{
if (h)
diff --git a/compose.c b/compose.c
index b4d0c41..27bc624 100644
--- a/compose.c
+++ b/compose.c
@@ -757,8 +757,8 @@ int mutt_compose_menu (HEADER *msg, /* structure for new
message */
menu->redraw = REDRAW_FULL;
- ctx = mx_open_mailbox (fname, MUTT_READONLY, NULL);
- if (ctx == NULL)
+ ctx = mx_open_mailbox (fname, MUTT_READONLY);
+ if (!ctx)
{
mutt_error (_("Unable to open mailbox %s"), fname);
break;
diff --git a/curs_main.c b/curs_main.c
index 8e0f52a..5310f6b 100644
--- a/curs_main.c
+++ b/curs_main.c
@@ -1266,9 +1266,10 @@ int mutt_index_menu (void)
CurrentMenu = MENU_MAIN;
mutt_folder_hook (buf);
- if ((Context = mx_open_mailbox (buf,
- (option (OPTREADONLY) || op ==
OP_MAIN_CHANGE_FOLDER_READONLY) ?
- MUTT_READONLY : 0, NULL)) != NULL)
+ Context = mx_open_mailbox (buf,
+ (option (OPTREADONLY) || op ==
OP_MAIN_CHANGE_FOLDER_READONLY) ?
+ MUTT_READONLY : 0);
+ if (Context)
{
menu->current = ci_first_message ();
}
diff --git a/editmsg.c b/editmsg.c
index 93384e9..35cda42 100644
--- a/editmsg.c
+++ b/editmsg.c
@@ -69,7 +69,7 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
omagic = DefaultMagic;
DefaultMagic = MUTT_MBOX;
- tmpctx = mx_open_mailbox (tmp, MUTT_NEWFOLDER, NULL);
+ tmpctx = mx_open_mailbox (tmp, MUTT_NEWFOLDER);
DefaultMagic = omagic;
@@ -144,7 +144,7 @@ static int edit_one_message (CONTEXT *ctx, HEADER *cur)
goto bail;
}
- tmpctx = mx_open_mailbox (ctx->path, MUTT_APPEND, NULL);
+ tmpctx = mx_open_mailbox (ctx->path, MUTT_APPEND);
if (!tmpctx)
{
rc = -1;
diff --git a/imap/imap.c b/imap/imap.c
index 2e3d27d..085813b 100644
--- a/imap/imap.c
+++ b/imap/imap.c
@@ -1245,7 +1245,7 @@ int imap_sync_mailbox (CONTEXT* ctx, int expunge, int*
index_hint)
mutt_message (_("Saving changed messages... [%d/%d]"), n+1,
ctx->msgcount);
if (!appendctx)
- appendctx = mx_open_mailbox (ctx->path, MUTT_APPEND | MUTT_QUIET,
NULL);
+ appendctx = mx_open_mailbox (ctx->path, MUTT_APPEND | MUTT_QUIET);
if (!appendctx)
dprint (1, (debugfile, "imap_sync_mailbox: Error opening mailbox in
append mode\n"));
else
diff --git a/mailbox.h b/mailbox.h
index 35fb601..cab24e6 100644
--- a/mailbox.h
+++ b/mailbox.h
@@ -58,7 +58,7 @@ typedef struct _message
time_t received; /* the time at which this message was received */
} MESSAGE;
-CONTEXT *mx_open_mailbox (const char *, int, CONTEXT *);
+CONTEXT *mx_open_mailbox (const char *, int);
MESSAGE *mx_open_message (CONTEXT *, int);
MESSAGE *mx_open_new_message (CONTEXT *, HEADER *, int);
diff --git a/main.c b/main.c
index 68a3601..50ec2aa 100644
--- a/main.c
+++ b/main.c
@@ -1218,7 +1218,7 @@ int main (int argc, char **argv)
mutt_folder_hook (folder);
- if((Context = mx_open_mailbox (folder, ((flags & MUTT_RO) || option
(OPTREADONLY)) ? MUTT_READONLY : 0, NULL))
+ if((Context = mx_open_mailbox (folder, ((flags & MUTT_RO) || option
(OPTREADONLY)) ? MUTT_READONLY : 0))
|| !explicit_folder)
{
#ifdef USE_SIDEBAR
diff --git a/mx.c b/mx.c
index f0833a5..75d414c 100644
--- a/mx.c
+++ b/mx.c
@@ -532,15 +532,12 @@ static int mx_close_mailbox_append (CONTEXT *ctx)
* MUTT_READONLY open mailbox in read-only mode
* MUTT_QUIET only print error messages
* MUTT_PEEK revert atime where applicable
- * ctx if non-null, context struct to use
*/
-CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
+CONTEXT *mx_open_mailbox (const char *path, int flags)
{
- CONTEXT *ctx = pctx;
+ CONTEXT *ctx = safe_malloc (sizeof (CONTEXT));
int rc;
- if (!ctx)
- ctx = safe_malloc (sizeof (CONTEXT));
memset (ctx, 0, sizeof (CONTEXT));
ctx->path = safe_strdup (path);
if (! (ctx->realpath = realpath (ctx->path, NULL)) )
@@ -564,8 +561,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags,
CONTEXT *pctx)
if (mx_open_mailbox_append (ctx, flags) != 0)
{
mx_fastclose_mailbox (ctx);
- if (!pctx)
- FREE (&ctx);
+ FREE (&ctx);
return NULL;
}
return ctx;
@@ -582,8 +578,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags,
CONTEXT *pctx)
mutt_perror(path);
mx_fastclose_mailbox (ctx);
- if (!pctx)
- FREE (&ctx);
+ FREE (&ctx);
return (NULL);
}
@@ -615,8 +610,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags,
CONTEXT *pctx)
else
{
mx_fastclose_mailbox (ctx);
- if (!pctx)
- FREE (&ctx);
+ FREE (&ctx);
}
unset_option (OPTFORCEREFRESH);
@@ -755,7 +749,7 @@ static int trash_append (CONTEXT *ctx)
}
#endif
- ctx_trash = mx_open_mailbox (TrashPath, MUTT_APPEND, NULL);
+ ctx_trash = mx_open_mailbox (TrashPath, MUTT_APPEND);
if (ctx_trash)
{
/* continue from initial scan above */
@@ -909,7 +903,7 @@ int mx_close_mailbox (CONTEXT *ctx, int *index_hint)
else /* use regular append-copy mode */
#endif
{
- CONTEXT *f = mx_open_mailbox (mbox, MUTT_APPEND, NULL);
+ CONTEXT *f = mx_open_mailbox (mbox, MUTT_APPEND);
if (!f)
{
diff --git a/pop.c b/pop.c
index 6ad97d4..531b848 100644
--- a/pop.c
+++ b/pop.c
@@ -856,7 +856,7 @@ void pop_fetch_mail (void)
goto finish;
}
- ctx = mx_open_mailbox (NONULL (Spoolfile), MUTT_APPEND, NULL);
+ ctx = mx_open_mailbox (NONULL (Spoolfile), MUTT_APPEND);
if (!ctx)
goto finish;
diff --git a/postpone.c b/postpone.c
index 9f03792..fc0fe83 100644
--- a/postpone.c
+++ b/postpone.c
@@ -130,7 +130,7 @@ int mutt_num_postponed (int force)
if (access (Postponed, R_OK | F_OK) != 0)
return (PostCount = 0);
- ctx = mx_open_mailbox (Postponed, MUTT_NOSORT | MUTT_QUIET, NULL);
+ ctx = mx_open_mailbox (Postponed, MUTT_NOSORT | MUTT_QUIET);
if (!ctx)
PostCount = 0;
else
@@ -243,7 +243,7 @@ int mutt_get_postponed (CONTEXT *ctx, HEADER *hdr, HEADER
**cur, char *fcc, size
if (!Postponed)
return (-1);
- if ((PostContext = mx_open_mailbox (Postponed, MUTT_NOSORT, NULL)) == NULL)
+ if ((PostContext = mx_open_mailbox (Postponed, MUTT_NOSORT)) == NULL)
{
PostCount = 0;
mutt_error _("No postponed messages.");
diff --git a/sendlib.c b/sendlib.c
index 2d48f87..7e02d43 100644
--- a/sendlib.c
+++ b/sendlib.c
@@ -2704,7 +2704,7 @@ int mutt_write_fcc (const char *path, HEADER *hdr, const
char *msgid, int post,
if (post)
set_noconv_flags (hdr->content, 1);
- f = mx_open_mailbox (path, MUTT_APPEND | MUTT_QUIET, NULL);
+ f = mx_open_mailbox (path, MUTT_APPEND | MUTT_QUIET);
if (!f)
{
dprint (1, (debugfile, "mutt_write_fcc(): unable to open mailbox %s in
append-mode, aborting.\n",
--
2.9.3