From 9b4503048e7d0eeb882aeea75140c2b6e3599c48 Mon Sep 17 00:00:00 2001 From: Jason Crain Date: Tue, 26 Nov 2019 23:44:15 -0700 Subject: glib: Use g_list_free_full Use g_list_free_full instead of g_list_foreach followed by g_list_free. This fixes a compiler warning. The g_list_foreach function takes a "GFunc" callback, which takes two arguments, but the free functions we pass only take one argument, so the compiler warns about an incompatible cast. Using g_list_free_full fixes this because it takes a "GDestroyNotify" callback, which takes one argument. --- glib/poppler-action.cc | 6 ++---- glib/poppler-document.cc | 10 +++------- glib/poppler-page.cc | 18 ++++++------------ 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/glib/poppler-action.cc b/glib/poppler-action.cc index 3efa8994..025e69f7 100644 --- a/glib/poppler-action.cc +++ b/glib/poppler-action.cc @@ -74,8 +74,7 @@ poppler_action_layer_free (PopplerActionLayer *action_layer) return; if (action_layer->layers) { - g_list_foreach (action_layer->layers, (GFunc)g_object_unref, nullptr); - g_list_free (action_layer->layers); + g_list_free_full (action_layer->layers, g_object_unref); action_layer->layers = nullptr; } @@ -136,8 +135,7 @@ poppler_action_free (PopplerAction *action) break; case POPPLER_ACTION_OCG_STATE: if (action->ocg_state.state_list) { - g_list_foreach (action->ocg_state.state_list, (GFunc)poppler_action_layer_free, nullptr); - g_list_free (action->ocg_state.state_list); + g_list_free_full (action->ocg_state.state_list, (GDestroyNotify)poppler_action_layer_free); } break; case POPPLER_ACTION_JAVASCRIPT: diff --git a/glib/poppler-document.cc b/glib/poppler-document.cc index e9c27796..e2d4f335 100644 --- a/glib/poppler-document.cc +++ b/glib/poppler-document.cc @@ -3127,8 +3127,7 @@ layer_free (Layer *layer) return; if (layer->kids) { - g_list_foreach (layer->kids, (GFunc)layer_free, nullptr); - g_list_free (layer->kids); + g_list_free_full (layer->kids, (GDestroyNotify)layer_free); } if (layer->label) { @@ -3276,11 +3275,8 @@ poppler_document_layers_free (PopplerDocument *document) if (G_UNLIKELY (!document->layers)) return; - g_list_foreach (document->layers, (GFunc)layer_free, nullptr); - g_list_free (document->layers); - - g_list_foreach (document->layers_rbgroups, (GFunc)g_list_free, nullptr); - g_list_free (document->layers_rbgroups); + g_list_free_full (document->layers, (GDestroyNotify)layer_free); + g_list_free_full (document->layers_rbgroups, (GDestroyNotify)g_list_free); document->layers = nullptr; document->layers_rbgroups = nullptr; diff --git a/glib/poppler-page.cc b/glib/poppler-page.cc index 0c43e768..da4939bb 100644 --- a/glib/poppler-page.cc +++ b/glib/poppler-page.cc @@ -729,8 +729,7 @@ poppler_page_selection_region_free (GList *region) if (G_UNLIKELY (!region)) return; - g_list_foreach (region, (GFunc)poppler_rectangle_free, nullptr); - g_list_free (region); + g_list_free_full (region, (GDestroyNotify)poppler_rectangle_free); } /** @@ -1117,8 +1116,7 @@ poppler_page_free_image_mapping (GList *list) if (G_UNLIKELY (list == nullptr)) return; - g_list_foreach (list, (GFunc)poppler_image_mapping_free, nullptr); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify)poppler_image_mapping_free); } /** @@ -1301,8 +1299,7 @@ poppler_page_free_link_mapping (GList *list) if (G_UNLIKELY (list == nullptr)) return; - g_list_foreach (list, (GFunc)poppler_link_mapping_free, nullptr); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify)poppler_link_mapping_free); } /** @@ -1368,8 +1365,7 @@ poppler_page_free_form_field_mapping (GList *list) if (G_UNLIKELY (list == nullptr)) return; - g_list_foreach (list, (GFunc) poppler_form_field_mapping_free, nullptr); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify)poppler_form_field_mapping_free); } /** @@ -1505,8 +1501,7 @@ poppler_page_free_annot_mapping (GList *list) if (G_UNLIKELY (!list)) return; - g_list_foreach (list, (GFunc)poppler_annot_mapping_free, nullptr); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify)poppler_annot_mapping_free); } /** @@ -2306,8 +2301,7 @@ poppler_page_free_text_attributes (GList *list) if (G_UNLIKELY (list == nullptr)) return; - g_list_foreach (list, (GFunc)poppler_text_attributes_free, nullptr); - g_list_free (list); + g_list_free_full (list, (GDestroyNotify)poppler_text_attributes_free); } static gboolean -- cgit v1.2.3