From 85cb61dbff32b998285c9c6e19df1b6f6eaa6354 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Tue, 4 Sep 2018 18:21:59 +0100 Subject: [PATCH] free_data --- mailbox.c | 9 +++++++-- mailbox.h | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) 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 */ -- 2.50.1