]> granicus.if.org Git - neomutt/commitdiff
Remove magic member in MESSAGE structure
authorDamien Riegel <damien.riegel@gmail.com>
Sat, 18 Jun 2016 19:41:43 +0000 (12:41 -0700)
committerDamien Riegel <damien.riegel@gmail.com>
Sat, 18 Jun 2016 19:41:43 +0000 (12:41 -0700)
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.

mailbox.h
mx.c

index c8939d47ed3f65dc4902b7a8ffebf9345e0a385c..1fb1efe0da632d33675feb55b5239c8094e7615e 100644 (file)
--- 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 bcb3a6bcfbb820f85f5526a3671450cc44f16c03..e6760a768eac3647183aa98551538f596f00a5e1 100644 (file)
--- 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);
   }