aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders <anders.broman@ericsson.com>2018-04-17 12:48:35 +0200
committerAnders Broman <a.broman58@gmail.com>2018-04-17 15:01:24 +0000
commit25a337cdb060962606c5caf7d918c2ed0aedf6e2 (patch)
tree49765468d8a9fee3a0c2faa79421a132677660bf
parent3dab804250ad4c648438fb23a107d74b51f4480f (diff)
glib: Use g_slist_free_full() in a couple of places.
Change-Id: Iff833bf5c197959c8decb62d6ce794c6d0415fb7 Reviewed-on: https://code.wireshark.org/review/26978 Petri-Dish: Anders Broman <a.broman58@gmail.com> Reviewed-by: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--capture_opts.c10
-rw-r--r--caputils/capture-pcap-util.c9
-rw-r--r--epan/color_filters.c5
-rw-r--r--epan/column-utils.c9
-rw-r--r--epan/dfilter/sttype-function.c5
-rw-r--r--epan/dfilter/sttype-set.c5
-rw-r--r--epan/exported_pdu.c9
-rw-r--r--epan/packet.c8
8 files changed, 13 insertions, 47 deletions
diff --git a/capture_opts.c b/capture_opts.c
index 7cc0c5d..8b249d6 100644
--- a/capture_opts.c
+++ b/capture_opts.c
@@ -1225,12 +1225,6 @@ capture_opts_free_interface_t_links(gpointer elem, gpointer unused _U_)
g_free(elem);
}
-static void
-capture_opts_free_interface_t_addrs(gpointer elem, gpointer unused _U_)
-{
- g_free(elem);
-}
-
void
capture_opts_free_interface_t(interface_t *device)
{
@@ -1253,9 +1247,7 @@ capture_opts_free_interface_t(interface_t *device)
g_free(device->if_info.name);
g_free(device->if_info.friendly_name);
g_free(device->if_info.vendor_description);
- g_slist_foreach(device->if_info.addrs,
- capture_opts_free_interface_t_addrs, NULL);
- g_slist_free(device->if_info.addrs);
+ g_slist_free_full(device->if_info.addrs, g_free);
g_free(device->if_info.extcap);
}
}
diff --git a/caputils/capture-pcap-util.c b/caputils/capture-pcap-util.c
index 581ed15..3464827 100644
--- a/caputils/capture-pcap-util.c
+++ b/caputils/capture-pcap-util.c
@@ -527,12 +527,6 @@ get_interface_list_findalldevs(int *err, char **err_str)
#endif /* HAVE_PCAP_FINDALLDEVS */
static void
-free_if_info_addr_cb(gpointer addr, gpointer user_data _U_)
-{
- g_free(addr);
-}
-
-static void
free_if_cb(gpointer data, gpointer user_data _U_)
{
if_info_t *if_info = (if_info_t *)data;
@@ -541,8 +535,7 @@ free_if_cb(gpointer data, gpointer user_data _U_)
g_free(if_info->friendly_name);
g_free(if_info->vendor_description);
g_free(if_info->extcap);
- g_slist_foreach(if_info->addrs, free_if_info_addr_cb, NULL);
- g_slist_free(if_info->addrs);
+ g_slist_free_full(if_info->addrs, g_free);
g_free(if_info);
}
diff --git a/epan/color_filters.c b/epan/color_filters.c
index be6d066..2b7f1b7 100644
--- a/epan/color_filters.c
+++ b/epan/color_filters.c
@@ -219,7 +219,7 @@ color_filter_delete(color_filter_t *colorf)
/* delete the specified filter (called from g_slist_foreach) */
static void
-color_filter_delete_cb(gpointer filter_arg, gpointer unused _U_)
+color_filter_delete_cb(gpointer filter_arg)
{
color_filter_t *colorf = (color_filter_t *)filter_arg;
@@ -230,8 +230,7 @@ color_filter_delete_cb(gpointer filter_arg, gpointer unused _U_)
void
color_filter_list_delete(GSList **cfl)
{
- g_slist_foreach(*cfl, color_filter_delete_cb, NULL);
- g_slist_free(*cfl);
+ g_slist_free_full(*cfl, color_filter_delete_cb);
*cfl = NULL;
}
diff --git a/epan/column-utils.c b/epan/column-utils.c
index 9b544eb..104739e 100644
--- a/epan/column-utils.c
+++ b/epan/column-utils.c
@@ -71,17 +71,10 @@ col_setup(column_info *cinfo, const gint num_cols)
}
static void
-col_custom_ids_free_wrapper(gpointer data, gpointer user_data _U_)
-{
- g_free(data);
-}
-
-static void
col_custom_fields_ids_free(GSList** custom_fields_id)
{
if (*custom_fields_id != NULL) {
- g_slist_foreach(*custom_fields_id, col_custom_ids_free_wrapper, NULL);
- g_slist_free(*custom_fields_id);
+ g_slist_free_full(*custom_fields_id, g_free);
}
*custom_fields_id = NULL;
}
diff --git a/epan/dfilter/sttype-function.c b/epan/dfilter/sttype-function.c
index 3d58543..73478b2 100644
--- a/epan/dfilter/sttype-function.c
+++ b/epan/dfilter/sttype-function.c
@@ -52,7 +52,7 @@ function_dup(gconstpointer data)
}
static void
-slist_stnode_free(gpointer data, gpointer user_data _U_)
+slist_stnode_free(gpointer data)
{
stnode_free((stnode_t *)data);
}
@@ -60,8 +60,7 @@ slist_stnode_free(gpointer data, gpointer user_data _U_)
void
st_funcparams_free(GSList *params)
{
- g_slist_foreach(params, slist_stnode_free, NULL);
- g_slist_free(params);
+ g_slist_free_full(params, slist_stnode_free);
}
static void
diff --git a/epan/dfilter/sttype-set.c b/epan/dfilter/sttype-set.c
index 8f460f4..8b4634a 100644
--- a/epan/dfilter/sttype-set.c
+++ b/epan/dfilter/sttype-set.c
@@ -12,7 +12,7 @@
#include "sttype-set.h"
static void
-slist_stnode_free(gpointer data, gpointer user_data _U_)
+slist_stnode_free(gpointer data)
{
stnode_free((stnode_t *)data);
}
@@ -20,8 +20,7 @@ slist_stnode_free(gpointer data, gpointer user_data _U_)
void
set_nodelist_free(GSList *params)
{
- g_slist_foreach(params, slist_stnode_free, NULL);
- g_slist_free(params);
+ g_slist_free_full(params, slist_stnode_free);
}
void
diff --git a/epan/exported_pdu.c b/epan/exported_pdu.c
index 5cc0a74..d260415 100644
--- a/epan/exported_pdu.c
+++ b/epan/exported_pdu.c
@@ -320,16 +320,9 @@ void export_pdu_init(void)
{
}
-static void
-free_list_element(gpointer elem, gpointer data _U_)
-{
- g_free(elem);
-}
-
void export_pdu_cleanup(void)
{
- g_slist_foreach(export_pdu_tap_name_list, free_list_element, NULL);
- g_slist_free(export_pdu_tap_name_list);
+ g_slist_free_full(export_pdu_tap_name_list, g_free);
}
/*
diff --git a/epan/packet.c b/epan/packet.c
index 80d754c..6383f65 100644
--- a/epan/packet.c
+++ b/epan/packet.c
@@ -139,8 +139,7 @@ destroy_depend_dissector_list(void *data)
depend_dissector_list_t dissector_list = (depend_dissector_list_t)data;
GSList **list = &(dissector_list->dissectors);
- g_slist_foreach(*list, (GFunc)g_free, NULL);
- g_slist_free(*list);
+ g_slist_free_full(*list, g_free);
g_slice_free(struct depend_dissector_list, dissector_list);
}
@@ -158,7 +157,7 @@ static GHashTable *heur_dissector_lists = NULL;
static GHashTable* heuristic_short_names = NULL;
static void
-destroy_heuristic_dissector_entry(gpointer data, gpointer user_data _U_)
+destroy_heuristic_dissector_entry(gpointer data)
{
heur_dtbl_entry_t *hdtbl_entry = (heur_dtbl_entry_t *)data;
g_free(hdtbl_entry->list_name);
@@ -172,8 +171,7 @@ destroy_heuristic_dissector_list(void *data)
heur_dissector_list_t dissector_list = (heur_dissector_list_t)data;
GSList **list = &(dissector_list->dissectors);
- g_slist_foreach(*list, destroy_heuristic_dissector_entry, NULL);
- g_slist_free(*list);
+ g_slist_free_full(*list, destroy_heuristic_dissector_entry);
g_slice_free(struct heur_dissector_list, dissector_list);
}