]> granicus.if.org Git - neomutt/commitdiff
unify private data free functions
authorRichard Russon <rich@flatcap.org>
Tue, 16 Jul 2019 19:44:32 +0000 (20:44 +0100)
committerRichard Russon <rich@flatcap.org>
Tue, 16 Jul 2019 21:17:50 +0000 (22:17 +0100)
core/account.c
core/mailbox.c
core/neomutt.c
email/email.c
email/email.h
mutt/hash.c
mutt/hash.h

index e8ba4399f51a60dede57a148bc4e07b654b4d41f..e1dc7e7de9314be6148c7cfda01a4e01d2f9e46d 100644 (file)
@@ -117,13 +117,12 @@ void account_free(struct Account **ptr)
     return;
 
   struct Account *a = *ptr;
-  account_mailbox_remove(a, NULL);
+  notify_free(&a->notify);
 
   if (a->free_adata)
     a->free_adata(&a->adata);
 
-  notify_free(&a->notify);
-  // account_free_config(a);
+  account_mailbox_remove(a, NULL);
   cs_subset_free(&a->sub);
   FREE(&a->name);
 
index 6e427c864f884bbf25204bafea43d87644c87484..07edf6fd0859c77f2ca24c0f2ffd5808ffd04348 100644 (file)
@@ -62,11 +62,13 @@ void mailbox_free(struct Mailbox **ptr)
   mailbox_changed(m, MBN_CLOSED);
   notify_free(&m->notify);
 
-  mutt_buffer_free(&m->pathbuf);
-  FREE(&m->name);
   if (m->mdata && m->free_mdata)
     m->free_mdata(&m->mdata);
+
+  mutt_buffer_free(&m->pathbuf);
+  FREE(&m->name);
   FREE(&m->realpath);
+
   FREE(ptr);
 }
 
index 9369e7beee7e855d9805197598e14513c43c429d..d6c919a3d8db085495b8117c6cf22485999afeb4 100644 (file)
@@ -66,9 +66,9 @@ void neomutt_free(struct NeoMutt **ptr)
     return;
 
   struct NeoMutt *n = *ptr;
+  notify_free(&n->notify);
 
   neomutt_account_remove(n, NULL);
-  notify_free(&n->notify);
   cs_subset_free(&n->sub);
 
   FREE(ptr);
index 4e83d97da82385566e848a185ad2a7a8ba6734a7..8d44603be1fc00e307a99fb9fb669cce5e50796a 100644 (file)
 
 /**
  * email_free - Free an Email
- * @param[out] e Email to free
+ * @param[out] ptr Email to free
  */
-void email_free(struct Email **e)
+void email_free(struct Email **ptr)
 {
-  if (!e || !*e)
+  if (!ptr || !*ptr)
     return;
-  mutt_env_free(&(*e)->env);
-  mutt_body_free(&(*e)->content);
-  FREE(&(*e)->maildir_flags);
-  FREE(&(*e)->tree);
-  FREE(&(*e)->path);
+
+  struct Email *e = *ptr;
+
+  if (e->edata && e->free_edata)
+    e->free_edata(&e->edata);
+
+  mutt_env_free(&e->env);
+  mutt_body_free(&e->content);
+  FREE(&e->maildir_flags);
+  FREE(&e->tree);
+  FREE(&e->path);
 #ifdef MIXMASTER
-  mutt_list_free(&(*e)->chain);
+  mutt_list_free(&e->chain);
 #endif
-  driver_tags_free(&(*e)->tags);
-  if ((*e)->edata && (*e)->free_edata)
-    (*e)->free_edata(&(*e)->edata);
-  FREE(e);
+  driver_tags_free(&e->tags);
+
+  FREE(ptr);
 }
 
 /**
index 0feaa6d6f9311db9721818a9198acd0d42049b0f..095464a1a7e389b0eb2b8b60d308cabf5f49eb7b 100644 (file)
@@ -122,7 +122,7 @@ struct EmailNode
 STAILQ_HEAD(EmailList, EmailNode);
 
 bool          email_cmp_strict(const struct Email *e1, const struct Email *e2);
-void          email_free      (struct Email **e);
+void          email_free      (struct Email **ptr);
 struct Email *email_new       (void);
 size_t        email_size      (const struct Email *e);
 
index 28607146b62548885e95fea15b845ae09ee58ee7..83dbde9ea1bcfbe6baeddedd31cf6d63106f093a 100644 (file)
@@ -251,8 +251,8 @@ static void union_hash_delete(struct Hash *table, union HashKey key, const void
     if (((data == ptr->data) || !data) && (table->cmp_key(ptr->key, key) == 0))
     {
       *last = ptr->next;
-      if (table->elem_free)
-        table->elem_free(ptr->type, ptr->data, table->hash_data);
+      if (table->free_hdata)
+        table->free_hdata(ptr->type, ptr->data, table->hdata);
       if (table->strdup_keys)
         FREE(&ptr->key.strkey);
       FREE(&ptr);
@@ -319,8 +319,8 @@ void mutt_hash_set_destructor(struct Hash *table, hashelem_free_t fn, intptr_t f
 {
   if (!table)
     return;
-  table->elem_free = fn;
-  table->hash_data = fn_data;
+  table->free_hdata = fn;
+  table->hdata = fn_data;
 }
 
 /**
@@ -466,7 +466,7 @@ void mutt_hash_int_delete(struct Hash *table, unsigned int intkey, const void *d
 }
 
 /**
- * mutt_hash_free - elem_free a hash table
+ * mutt_hash_free - free_hdata a hash table
  * @param[out] ptr Hash Table to be freed
  */
 void mutt_hash_free(struct Hash **ptr)
@@ -483,8 +483,8 @@ void mutt_hash_free(struct Hash **ptr)
     {
       tmp = elem;
       elem = elem->next;
-      if (pptr->elem_free)
-        pptr->elem_free(tmp->type, tmp->data, pptr->hash_data);
+      if (pptr->free_hdata)
+        pptr->free_hdata(tmp->type, tmp->data, pptr->hdata);
       if (pptr->strdup_keys)
         FREE(&tmp->key.strkey);
       FREE(&tmp);
index dbd980f28a3f4adfb865895f90ef06996b35a892..97a13088dbdc3cbd0d9d91fb9949b1fd95d51705 100644 (file)
@@ -60,14 +60,14 @@ typedef void (*hashelem_free_t)(int type, void *obj, intptr_t data);
  */
 struct Hash
 {
-  size_t nelem;            ///< Number of elements in the Hash table
-  bool strdup_keys : 1;    ///< if set, the key->strkey is strdup'ed
-  bool allow_dups  : 1;    ///< if set, duplicate keys are allowed
-  struct HashElem **table; ///< Array of Hash keys
+  size_t nelem;                                 ///< Number of elements in the Hash table
+  bool strdup_keys : 1;                         ///< if set, the key->strkey is strdup'ed
+  bool allow_dups  : 1;                         ///< if set, duplicate keys are allowed
+  struct HashElem **table;                      ///< Array of Hash keys
   size_t (*gen_hash)(union HashKey, size_t);    ///< Function to generate hash id from the key
   int (*cmp_key)(union HashKey, union HashKey); ///< Function to compare two Hash keys
-  hashelem_free_t elem_free; ///< Function to free a Hash element
-  intptr_t hash_data;        ///< Data to pass to the elem_free() function
+  intptr_t hdata;                               ///< Data to pass to the free_hdata() function
+  hashelem_free_t free_hdata;                   ///< Function to free a Hash element
 };
 
 typedef uint8_t HashFlags;             ///< Flags for mutt_hash_new(), e.g. #MUTT_HASH_STRCASECMP