]> granicus.if.org Git - neomutt/commitdiff
factor out Context from msg_padding_size()
authorRichard Russon <rich@flatcap.org>
Wed, 21 Nov 2018 14:25:41 +0000 (14:25 +0000)
committerRichard Russon <rich@flatcap.org>
Thu, 22 Nov 2018 13:45:24 +0000 (13:45 +0000)
index.c
mutt_thread.c
mx.c
mx.h
pattern.c

diff --git a/index.c b/index.c
index 1dc760f21fcf89cda23abaa21c63078688a72718..dc28ac427e81ba89b1af6a547e3e34f964613a23 100644 (file)
--- a/index.c
+++ b/index.c
@@ -461,7 +461,7 @@ static void update_index_unthreaded(struct Context *ctx, int check, int oldcount
    * they will be visible in the limited view */
   if (ctx->pattern)
   {
-    int padding = mx_msg_padding_size(ctx);
+    int padding = mx_msg_padding_size(ctx->mailbox);
     for (int i = (check == MUTT_REOPENED) ? 0 : oldcount; i < ctx->mailbox->msg_count; i++)
     {
       if (!i)
index e81d7b06dab5bee75dbfc4548ef4189965cefc18..b939c38d97b0d2b6ae3d3baeba841385c470c641 100644 (file)
@@ -1195,7 +1195,7 @@ void mutt_set_virtual(struct Context *ctx)
 
   m->vcount = 0;
   ctx->vsize = 0;
-  int padding = mx_msg_padding_size(ctx);
+  int padding = mx_msg_padding_size(m);
 
   for (int i = 0; i < m->msg_count; i++)
   {
diff --git a/mx.c b/mx.c
index 1430dfb45a755bc4192bc899039bc0c494b5f778..17744b9f1dd21302e7b76f717cc1bf0515da6888 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -830,7 +830,7 @@ void mx_update_tables(struct Context *ctx, bool committing)
   m->msg_unread = 0;
   m->changed = false;
   m->msg_flagged = 0;
-  padding = mx_msg_padding_size(ctx);
+  padding = mx_msg_padding_size(m);
   for (i = 0, j = 0; i < m->msg_count; i++)
   {
     if (!m->hdrs[i]->quasi_deleted &&
@@ -1623,20 +1623,15 @@ int mx_path_parent(char *buf, size_t buflen)
 
 /**
  * mx_msg_padding_size - Bytes of padding between messages - Wrapper for MxOps::msg_padding_size
- * @param ctx Mailbox
+ * @param m Mailbox
  * @retval num Number of bytes of padding
  *
  * mmdf and mbox add separators, which leads a small discrepancy when computing
  * vsize for a limited view.
  */
-int mx_msg_padding_size(struct Context *ctx)
+int mx_msg_padding_size(struct Mailbox *m)
 {
-  if (!ctx || !ctx->mailbox)
-    return 0;
-
-  struct Mailbox *m = ctx->mailbox;
-
-  if (!m->mx_ops || !m->mx_ops->msg_padding_size)
+  if (!m || !m->mx_ops || !m->mx_ops->msg_padding_size)
     return 0;
 
   return m->mx_ops->msg_padding_size(m);
diff --git a/mx.h b/mx.h
index 3cbe525344a68ed5e295d7e68b01bafb85778d86..cb3c2d74b31894f3753c61e3fdc850084aaa4630 100644 (file)
--- a/mx.h
+++ b/mx.h
@@ -259,12 +259,12 @@ int             mx_msg_close       (struct Mailbox *m, struct Message **msg);
 int             mx_msg_commit      (struct Context *ctx, struct Message *msg);
 struct Message *mx_msg_open_new    (struct Mailbox *m, struct Email *e, int flags);
 struct Message *mx_msg_open        (struct Mailbox *m, int msgno);
-int             mx_msg_padding_size(struct Context *ctx);
+int             mx_msg_padding_size(struct Mailbox *m);
 int             mx_path_canon      (char *buf, size_t buflen, const char *folder, int *magic);
 int             mx_path_canon2     (struct Mailbox *m, const char *folder);
 int             mx_path_parent     (char *buf, size_t buflen);
 int             mx_path_pretty     (char *buf, size_t buflen, const char *folder);
-enum MailboxType   mx_path_probe      (const char *path, struct stat *st);
+enum MailboxType mx_path_probe     (const char *path, struct stat *st);
 int             mx_tags_commit     (struct Context *ctx, struct Email *e, char *tags);
 int             mx_tags_edit       (struct Context *ctx, const char *tags, char *buf, size_t buflen);
 
index b4b8759e06add1264e8d6b078c73adf099c2f61d..af093b0f5e75ef61e52ea18cfb7e84b63485999e 100644 (file)
--- a/pattern.c
+++ b/pattern.c
@@ -2255,7 +2255,7 @@ int mutt_pattern_func(int op, char *prompt)
     Context->mailbox->vcount = 0;
     Context->vsize = 0;
     Context->collapsed = false;
-    padding = mx_msg_padding_size(Context);
+    padding = mx_msg_padding_size(Context->mailbox);
 
     for (int i = 0; i < Context->mailbox->msg_count; i++)
     {