From: Richard Russon Date: Wed, 3 Jul 2019 12:58:35 +0000 (+0100) Subject: rename account_remove_mailbox() X-Git-Tag: 2019-10-25~148^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=27ac8c5f5bb85eb40eb4fce7aa1dc858046267e2;p=neomutt rename account_remove_mailbox() --- diff --git a/account.c b/account.c index b8808d345..96a013efb 100644 --- a/account.c +++ b/account.c @@ -119,38 +119,23 @@ void account_free_config(struct Account *a) } /** - * account_free - Free an Account - * @param[out] ptr Account to free - */ -void account_free(struct Account **ptr) -{ - if (!ptr || !*ptr) - return; - - struct Account *a = *ptr; - if (!TAILQ_EMPTY(&AllAccounts)) - TAILQ_REMOVE(&AllAccounts, a, entries); - if (a->free_adata) - a->free_adata(&a->adata); - - account_free_config(a); - - FREE(ptr); -} - -/** - * account_remove_mailbox - Remove a Mailbox from an Account + * account_mailbox_remove - Remove a Mailbox from an Account * @param a Account * @param m Mailbox to remove */ -void account_remove_mailbox(struct Account *a, struct Mailbox *m) +bool account_mailbox_remove(struct Account *a, struct Mailbox *m) { + if (!a) + return false; + + bool result = false; struct MailboxNode *np = NULL; STAILQ_FOREACH(np, &a->mailboxes, entries) { if (np->mailbox == m) { STAILQ_REMOVE(&a->mailboxes, np, MailboxNode, entries); + result = true; break; } } @@ -159,6 +144,27 @@ void account_remove_mailbox(struct Account *a, struct Mailbox *m) { account_free(&a); } + return result; +} + +/** + * account_free - Free an Account + * @param[out] ptr Account to free + */ +void account_free(struct Account **ptr) +{ + if (!ptr || !*ptr) + return; + + struct Account *a = *ptr; + if (!TAILQ_EMPTY(&AllAccounts)) + TAILQ_REMOVE(&AllAccounts, a, entries); + if (a->free_adata) + a->free_adata(&a->adata); + + account_free_config(a); + + FREE(ptr); } /** diff --git a/account.h b/account.h index 2be4f49cc..2f21b2d43 100644 --- a/account.h +++ b/account.h @@ -24,7 +24,8 @@ #ifndef MUTT_ACCOUNT_H #define MUTT_ACCOUNT_H -#include "mutt/queue.h" +#include +#include "mutt/mutt.h" #include "config/lib.h" #include "mailbox.h" @@ -55,8 +56,8 @@ bool account_add_config(struct Account *a, const struct ConfigSet *cs void account_free(struct Account **ptr); void account_free_config(struct Account *a); int account_get_value(const struct Account *a, size_t vid, struct Buffer *result); +bool account_mailbox_remove(struct Account *a, struct Mailbox *m); struct Account *account_new(void); -void account_remove_mailbox(struct Account *a, struct Mailbox *m); int account_set_value(const struct Account *a, size_t vid, intptr_t value, struct Buffer *err); #endif /* MUTT_ACCOUNT_H */ diff --git a/mx.c b/mx.c index 5faa4e5ee..0d4f7796a 100644 --- a/mx.c +++ b/mx.c @@ -1587,7 +1587,7 @@ int mx_ac_remove(struct Mailbox *m) if (!m || !m->account) return -1; - account_remove_mailbox(m->account, m); + account_mailbox_remove(m->account, m); return 0; }