Remove tree_path_free_wrapper
authorArkadiy Illarionov <qarkai@gmail.com>
Wed, 19 Jul 2023 19:48:19 +0000 (22:48 +0300)
committerColin Clark <colin.clark@cclark.uk>
Sat, 22 Jul 2023 15:43:14 +0000 (16:43 +0100)
src/dupe.cc
src/misc.cc
src/misc.h
src/search.cc
src/view-file/view-file-list.cc

index fbb1dcf..0a0ac4e 100644 (file)
@@ -847,8 +847,7 @@ static GList *dupe_listview_get_selection(DupeWindow *UNUSED(dw), GtkWidget *lis
                        }
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        return g_list_reverse(list);
 }
@@ -875,8 +874,7 @@ static gboolean dupe_listview_item_is_selected(DupeWindow *UNUSED(dw), DupeItem
                if (di_n == di) found = TRUE;
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        return found;
 }
@@ -3254,8 +3252,7 @@ static void dupe_window_remove_selection(DupeWindow *dw, GtkWidget *listview)
                if (di) list = g_list_prepend(list, di);
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        dw->color_frozen = TRUE;
        work = list;
@@ -4224,8 +4221,7 @@ static gboolean dupe_window_keypress_cb(GtkWidget *widget, GdkEventKey *event, g
                gtk_tree_model_get_iter(store, &iter, tpath);
                gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, -1);
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        if (event->state & GDK_CONTROL_MASK)
                {
index 36823a8..59f2738 100644 (file)
@@ -383,11 +383,6 @@ gint get_cpu_cores()
     return sysconf(_SC_NPROCESSORS_ONLN);
 }
 
-void tree_path_free_wrapper(void *data, void *UNUSED(useradata))
-{
-       gtk_tree_path_free(static_cast<GtkTreePath *>(data));
-}
-
 /* Copied from the libarchive .repo. examples */
 
 #ifndef HAVE_ARCHIVE
index c1a729b..00259ea 100644 (file)
@@ -32,7 +32,6 @@ gchar *date_get_abbreviated_day_name(gint day);
 gchar *convert_rating_to_stars(gint rating);
 gchar *get_symbolic_link(const gchar *path_utf8);
 gint get_cpu_cores();
-void tree_path_free_wrapper(void *data, void *useradata);
 gchar *open_archive(FileData *fd);
 #endif /* MISC_H */
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index 2fb9342..e4166f4 100644 (file)
@@ -491,8 +491,7 @@ static gboolean search_result_row_selected(SearchData *sd, FileData *fd)
                if (mfd_n->fd == fd) found = TRUE;
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        return found;
 }
@@ -530,8 +529,7 @@ static gint search_result_selection_util(SearchData *sd, gint64 *bytes, GList **
 
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        if (bytes) *bytes = total;
        if (list) *list = g_list_reverse(plist);
@@ -748,8 +746,7 @@ static void search_result_remove_selection(SearchData *sd)
                flist = g_list_prepend(flist, mfd->fd);
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        work = flist;
        while (work)
@@ -1350,8 +1347,7 @@ static gboolean search_result_keypress_cb(GtkWidget *widget, GdkEventKey *event,
                gtk_tree_model_get_iter(store, &iter, tpath);
                gtk_tree_model_get(store, &iter, SEARCH_COLUMN_POINTER, &mfd, -1);
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        if (event->state & GDK_CONTROL_MASK)
                {
index fe355e3..a5df05f 100644 (file)
@@ -1416,8 +1416,7 @@ static gboolean vflist_row_is_selected(ViewFile *vf, FileData *fd)
                if (fd_n == fd) found = TRUE;
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        return found;
 }
@@ -1466,8 +1465,7 @@ guint vflist_selection_count(ViewFile *vf, gint64 *bytes)
                }
 
        count = g_list_length(slist);
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        return count;
 }
@@ -1508,8 +1506,7 @@ GList *vflist_selection_get_list(ViewFile *vf)
 
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        return g_list_reverse(list);
 }
@@ -1538,8 +1535,7 @@ GList *vflist_selection_get_list_by_index(ViewFile *vf)
 
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 
        return g_list_reverse(list);
 }
@@ -1793,8 +1789,7 @@ void vflist_selection_to_mark(ViewFile *vf, gint mark, SelectionToMarkMode mode)
 
                work = work->next;
                }
-       g_list_foreach(slist, static_cast<GFunc>(tree_path_free_wrapper), nullptr);
-       g_list_free(slist);
+       g_list_free_full(slist, reinterpret_cast<GDestroyNotify>(gtk_tree_path_free));
 }
 
 /*