[balsa/wip/gtk4] Do not cast 'destroy' in g_clear_pointer()



commit acb0aa256cec48c61fc2dd1d4d8e846e6eba2f6a
Author: Peter Bloomfield <PeterBloomfield bellsouth net>
Date:   Wed Jul 11 16:09:24 2018 -0400

    Do not cast 'destroy' in g_clear_pointer()
    
    Do not cast the 'destroy' argument in g_clear_pointer() to
    '(GDestroyNotify)'; the new macro is type-safe, so we must use the correct
    destroyer.

 libbalsa/completion.c       | 12 ++++++------
 libbalsa/mailbox.c          |  5 +++--
 src/balsa-app.c             |  6 +++---
 src/balsa-message.c         |  6 +++---
 src/filter-edit-callbacks.c |  2 +-
 5 files changed, 16 insertions(+), 15 deletions(-)
---
diff --git a/libbalsa/completion.c b/libbalsa/completion.c
index 840a3204d..03b5a2d2a 100644
--- a/libbalsa/completion.c
+++ b/libbalsa/completion.c
@@ -168,8 +168,8 @@ libbalsa_completion_add_items(LibBalsaCompletion * cmp,
     g_return_if_fail(cmp != NULL);
 
     /* optimize adding to cache? */
-    g_clear_pointer(&cmp->cache, (GDestroyNotify) g_list_free);
-    g_clear_pointer(&cmp->prefix, (GDestroyNotify) g_free);
+    g_clear_pointer(&cmp->cache, g_list_free);
+    g_clear_pointer(&cmp->prefix, g_free);
 
     for (it = items; it != NULL; it = it->next) {
         cmp->items = g_list_prepend(cmp->items, it->data);
@@ -188,8 +188,8 @@ libbalsa_completion_clear_items(LibBalsaCompletion * cmp)
     g_return_if_fail(cmp != NULL);
 
     libbalsa_clear_list(&cmp->items, (GDestroyNotify) completion_data_free);
-    g_clear_pointer(&cmp->cache, (GDestroyNotify) g_list_free);
-    g_clear_pointer(&cmp->prefix, (GDestroyNotify) g_free);
+    g_clear_pointer(&cmp->cache, g_list_free);
+    g_clear_pointer(&cmp->prefix, g_free);
 }
 
 /**
@@ -238,7 +238,7 @@ libbalsa_completion_complete(LibBalsaCompletion * cmp,
 
     if (!done) {
         /* normal code */
-        g_clear_pointer(&cmp->cache, (GDestroyNotify) g_list_free);
+        g_clear_pointer(&cmp->cache, g_list_free);
         for (list = cmp->items; list != NULL && *prefix != '\0'; list = list->next) {
             if (cmp->strncmp_func(prefix,
                                   cmp->func ? cmp->func(list->data)
@@ -248,7 +248,7 @@ libbalsa_completion_complete(LibBalsaCompletion * cmp,
             }
         }
     }
-    g_clear_pointer(&cmp->prefix, (GDestroyNotify) g_free);
+    g_clear_pointer(&cmp->prefix, g_free);
     if (cmp->cache != NULL)
         cmp->prefix = g_strdup(prefix);
 
diff --git a/libbalsa/mailbox.c b/libbalsa/mailbox.c
index b608e5cb0..6ab56bb02 100644
--- a/libbalsa/mailbox.c
+++ b/libbalsa/mailbox.c
@@ -581,7 +581,8 @@ libbalsa_mailbox_free_mindex(LibBalsaMailbox *mailbox)
 
     if (priv->mindex != NULL) {
         g_ptr_array_foreach(priv->mindex, (GFunc) lbm_index_entry_free, NULL);
-        g_clear_pointer(&priv->mindex, (GDestroyNotify) g_ptr_array_free);
+        g_ptr_array_free(priv->mindex, TRUE);
+        priv->mindex = NULL;
     }
 }
 
@@ -686,7 +687,7 @@ libbalsa_mailbox_close(LibBalsaMailbox *mailbox,
         /* do not try expunging read-only mailboxes, it's a waste of time */
         expunge = expunge && !priv->readonly;
         LIBBALSA_MAILBOX_GET_CLASS(mailbox)->close_mailbox(mailbox, expunge);
-        g_clear_pointer(&priv->msg_tree, (GDestroyNotify) g_node_destroy);
+        g_clear_pointer(&priv->msg_tree, g_node_destroy);
         libbalsa_mailbox_free_mindex(mailbox);
         priv->stamp++;
         priv->state = LB_MAILBOX_STATE_CLOSED;
diff --git a/src/balsa-app.c b/src/balsa-app.c
index 9b117d231..85b3489a4 100644
--- a/src/balsa-app.c
+++ b/src/balsa-app.c
@@ -421,7 +421,7 @@ balsa_app_destroy(void)
     /* now free filters */
     g_slist_foreach(balsa_app.filters, (GFunc)libbalsa_filter_free,
                    GINT_TO_POINTER(TRUE));
-    g_clear_pointer(&balsa_app.filters, (GDestroyNotify) g_slist_free);
+    g_clear_pointer(&balsa_app.filters, g_slist_free);
 
     libbalsa_clear_list(&balsa_app.identities, g_object_unref);
     libbalsa_clear_list(&balsa_app.folder_mru, g_free);
@@ -678,8 +678,8 @@ balsa_quote_regex_new(void)
     if (g_strcmp0(string, balsa_app.quote_regex) != 0) {
         /* We have not initialized the GRegex, or balsa_app.quote_regex
          * has changed. */
-        g_clear_pointer(&string, (GDestroyNotify) g_free);
-        g_clear_pointer(&regex,  (GDestroyNotify) g_regex_unref);
+        g_clear_pointer(&string, g_free);
+        g_clear_pointer(&regex, g_regex_unref);
     }
 
     if (regex == NULL) {
diff --git a/src/balsa-message.c b/src/balsa-message.c
index 1544ecc3f..85adc1826 100644
--- a/src/balsa-message.c
+++ b/src/balsa-message.c
@@ -825,7 +825,7 @@ balsa_message_destroy(GObject * object)
         bm->treeview = NULL;
     }
 
-    g_clear_pointer(&bm->save_all_list, (GDestroyNotify) g_list_free);
+    g_clear_pointer(&bm->save_all_list, g_list_free);
     g_clear_object(&bm->save_all_popup);
     g_clear_object(&bm->parts_popup);
     g_clear_object(&bm->bm_widget);
@@ -932,7 +932,7 @@ tree_mult_selection_popup(BalsaMessage * bm, const GdkEvent * event,
     gint selected;
 
     /* destroy left-over select list and popup... */
-    g_clear_pointer(&bm->save_all_list, (GDestroyNotify) g_list_free);
+    g_clear_pointer(&bm->save_all_list, g_list_free);
     g_clear_object(&bm->save_all_popup);
 
     /* collect all selected info blocks */
@@ -955,7 +955,7 @@ tree_mult_selection_popup(BalsaMessage * bm, const GdkEvent * event,
                                          NULL);
             }
         }
-        g_clear_pointer(&bm->save_all_list, (GDestroyNotify) g_list_free);
+        g_clear_pointer(&bm->save_all_list, g_list_free);
     } else if (selected > 1) {
         GtkWidget *menu_item;
 
diff --git a/src/filter-edit-callbacks.c b/src/filter-edit-callbacks.c
index 492d6eecb..c7f4cac62 100644
--- a/src/filter-edit-callbacks.c
+++ b/src/filter-edit-callbacks.c
@@ -1426,7 +1426,7 @@ void fe_destroy_window_cb(GtkWidget * widget,gpointer throwaway)
         g_free(((filters_names_rec *)lst->data)->new_name);
         g_free((filters_names_rec *)lst->data);
     }
-    g_clear_pointer(&filters_names_changes, (GDestroyNotify) g_list_free);
+    g_clear_pointer(&filters_names_changes, g_list_free);
 
     libbalsa_clear_list(&new_filters_names, g_free);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]