From: Richard Russon Date: Mon, 5 Nov 2018 22:54:20 +0000 (+0000) Subject: nntp: reorg cleanup X-Git-Tag: 2019-10-25~511^2~7 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bd8143c5e29bcdbcd2d65dec7c3db01821260b28;p=neomutt nntp: reorg cleanup --- diff --git a/nntp/newsrc.c b/nntp/newsrc.c index b34108683..f38b8a883 100644 --- a/nntp/newsrc.c +++ b/nntp/newsrc.c @@ -121,7 +121,7 @@ void nntp_acache_free(struct NntpMboxData *mdata) */ void nntp_hash_destructor_t(int type, void *obj, intptr_t data) { - nntp_mdata_free(obj); + nntp_mdata_free(&obj); } /** diff --git a/nntp/nntp.c b/nntp/nntp.c index dc0c7520a..1e4bbb1ae 100644 --- a/nntp/nntp.c +++ b/nntp/nntp.c @@ -166,17 +166,18 @@ struct NntpAccountData *nntp_adata_get(struct Mailbox *m) * nntp_mdata_free - Free NntpMboxData, used to destroy hash elements * @param ptr NNTP data */ -void nntp_mdata_free(void *ptr) +void nntp_mdata_free(void **ptr) { - struct NntpMboxData *mdata = ptr; - - if (!mdata) + if (!ptr || !*ptr) return; + + struct NntpMboxData *mdata = *ptr; + nntp_acache_free(mdata); mutt_bcache_close(&mdata->bcache); FREE(&mdata->newsrc_ent); FREE(&mdata->desc); - FREE(&ptr); + FREE(ptr); } /** @@ -2563,6 +2564,7 @@ static int nntp_mbox_open(struct Context *ctx) time(&adata->check_time); m->mdata = mdata; + m->free_mdata = nntp_mdata_free; if (!mdata->bcache && (mdata->newsrc_ent || mdata->subscribed || SaveUnsubscribed)) mdata->bcache = mutt_bcache_open(&adata->conn->account, mdata->group); @@ -2712,7 +2714,7 @@ static int nntp_mbox_close(struct Context *ctx) tmp_mdata = mutt_hash_find(mdata->adata->groups_hash, mdata->group); if (!tmp_mdata || tmp_mdata != mdata) - nntp_mdata_free(mdata); + nntp_mdata_free((void **) &mdata); return 0; } diff --git a/nntp/nntp_private.h b/nntp/nntp_private.h index 99400fe18..9ea94c00c 100644 --- a/nntp/nntp_private.h +++ b/nntp/nntp_private.h @@ -58,7 +58,7 @@ void nntp_delete_group_cache(struct NntpMboxData *mdata); struct NntpEmailData *nntp_edata_get(struct Email *e); void nntp_group_unread_stat(struct NntpMboxData *mdata); void nntp_hash_destructor_t(int type, void *obj, intptr_t data); -void nntp_mdata_free(void *ptr); +void nntp_mdata_free(void **ptr); void nntp_newsrc_gen_entries(struct Context *ctx); int nntp_open_connection(struct NntpAccountData *adata);