]> granicus.if.org Git - neomutt/commitdiff
free_data
authorRichard Russon <rich@flatcap.org>
Tue, 4 Sep 2018 17:21:59 +0000 (18:21 +0100)
committerRichard Russon <rich@flatcap.org>
Sun, 9 Sep 2018 15:09:58 +0000 (16:09 +0100)
mailbox.c
mailbox.h

index 3d52f2d5743aea208b89d389653bab9dc3c732f1..8aead75f13fc31c3099245c9662085a129909e7c 100644 (file)
--- 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);
 }
 
index e99175433cbb7c98411c4f093db977a63aad0eb7..7c572db537aece9810a7961ad70965bd3160743c 100644 (file)
--- 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 */