From: Richard Russon Date: Tue, 4 Sep 2018 17:21:59 +0000 (+0100) Subject: free_data X-Git-Tag: 2019-10-25~657^2~20 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=85cb61dbff32b998285c9c6e19df1b6f6eaa6354;p=neomutt free_data --- diff --git a/mailbox.c b/mailbox.c index 3d52f2d57..8aead75f1 100644 --- a/mailbox.c +++ b/mailbox.c @@ -201,8 +201,13 @@ struct Mailbox *mailbox_new(const char *path) */ void mailbox_free(struct Mailbox **mailbox) { - if (mailbox && *mailbox) - FREE(&(*mailbox)->desc); + if (!mailbox || !*mailbox) + return; + + FREE(&(*mailbox)->desc); + if ((*mailbox)->free_data) + (*mailbox)->free_data((*mailbox)->data); + FREE(mailbox); } diff --git a/mailbox.h b/mailbox.h index e99175433..7c572db53 100644 --- a/mailbox.h +++ b/mailbox.h @@ -73,8 +73,8 @@ struct Mailbox struct timespec last_visited; /**< time of last exit from this mailbox */ struct timespec stats_last_checked; /**< mtime of mailbox the last time stats where checked. */ - /* driver hooks */ - void *data; /**< driver specific data */ + void *data; /**< driver specific data */ + void (*free_data)(void *); /**< driver-specific data free function */ const struct MxOps *mx_ops; bool changed : 1; /**< mailbox has been modified */