From: Damien Riegel Date: Sat, 18 Jun 2016 19:41:43 +0000 (-0700) Subject: Remove magic member in MESSAGE structure X-Git-Tag: mutt-1-7-rel~65 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8778153bac54fd9914bab8b1b23d30bde575fc80;p=mutt Remove magic member in MESSAGE structure The "magic" was copied from the context to the message structure to be able to determine which close function had to be called in mx_close_message. Now that this function is context aware, there is no need to store the magic in the MESSAGE structure and it can be safely removed. --- diff --git a/mailbox.h b/mailbox.h index c8939d47..1fb1efe0 100644 --- a/mailbox.h +++ b/mailbox.h @@ -45,7 +45,6 @@ typedef struct _message { FILE *fp; /* pointer to the message data */ char *path; /* path to temp file */ - short magic; /* type of mailbox this message belongs to */ short write; /* nonzero if message is open for writing */ struct { unsigned read : 1; diff --git a/mx.c b/mx.c index bcb3a6bc..e6760a76 100644 --- a/mx.c +++ b/mx.c @@ -1245,7 +1245,6 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags) } msg = safe_calloc (1, sizeof (MESSAGE)); - msg->magic = dest->magic; msg->write = 1; if (hdr) @@ -1265,7 +1264,7 @@ MESSAGE *mx_open_new_message (CONTEXT *dest, HEADER *hdr, int flags) if (dest->magic == MUTT_MMDF) fputs (MMDF_SEP, msg->fp); - if ((msg->magic == MUTT_MBOX || msg->magic == MUTT_MMDF) && + if ((dest->magic == MUTT_MBOX || dest->magic == MUTT_MMDF) && flags & MUTT_ADD_FROM) { if (hdr) @@ -1319,7 +1318,6 @@ MESSAGE *mx_open_message (CONTEXT *ctx, int msgno) } msg = safe_calloc (1, sizeof (MESSAGE)); - msg->magic = ctx->magic; ret = ops->open_msg (ctx, msg, msgno); if (ret) FREE (&msg); @@ -1340,7 +1338,7 @@ int mx_commit_message (MESSAGE *msg, CONTEXT *ctx) return -1; } - switch (msg->magic) + switch (ctx->magic) { case MUTT_MMDF: { @@ -1393,8 +1391,8 @@ int mx_close_message (CONTEXT *ctx, MESSAGE **msg) { int r = 0; - if ((*msg)->magic == MUTT_MH || (*msg)->magic == MUTT_MAILDIR - || (*msg)->magic == MUTT_IMAP || (*msg)->magic == MUTT_POP) + if (ctx->magic == MUTT_MH || ctx->magic == MUTT_MAILDIR + || ctx->magic == MUTT_IMAP || ctx->magic == MUTT_POP) { r = safe_fclose (&(*msg)->fp); }