summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Crain <jason@inspiresomeone.us>2019-11-26 23:44:15 -0700
committerAlbert Astals Cid <tsdgeos@yahoo.es>2019-11-28 18:35:54 +0000
commit9b4503048e7d0eeb882aeea75140c2b6e3599c48 (patch)
tree2925a141a3732cd0bba491565fe7b6a6e2d3bb6a
parent1496a00af0cb5f4c39d255493501957ef6a7f7da (diff)
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.
-rw-r--r--glib/poppler-action.cc6
-rw-r--r--glib/poppler-document.cc10
-rw-r--r--glib/poppler-page.cc18
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