if (!m || !*m)
return;
+ if (Context && Context->mailbox && Context->mailbox == *m)
+ {
+ mx_cleanup_context(Context);
+ FREE(&Context);
+ }
+
FREE(&(*m)->desc);
if ((*m)->mdata && (*m)->free_mdata)
(*m)->free_mdata(&(*m)->mdata);
- if (Context && Context->mailbox && Context->mailbox == *m)
- Context = NULL;
FREE(m);
}
FREE(&ctx->mailbox->hdrs);
}
FREE(&ctx->mailbox->v2r);
- FREE(&ctx->pattern);
- if (ctx->limit_pattern)
- mutt_pattern_free(&ctx->limit_pattern);
- memset(ctx, 0, sizeof(struct Context));
+ mx_cleanup_context(ctx);
}
/**
account_remove_mailbox(m->account, m);
return 0;
}
+
+
+/**
+ * mx_cleanup_context - Release memory and initialize a Context object
+ * @param ctx Context to cleanup
+ */
+void mx_cleanup_context(struct Context *ctx)
+{
+ FREE(&ctx->pattern);
+ if (ctx->limit_pattern)
+ mutt_pattern_free(&ctx->limit_pattern);
+ memset(ctx, 0, sizeof(struct Context));
+}
+
bool mx_tags_is_supported(struct Context *ctx);
void mx_update_context(struct Context *ctx, int new_messages);
void mx_update_tables(struct Context *ctx, bool committing);
+void mx_cleanup_context(struct Context *ctx);
#endif /* MUTT_MX_H */