summaryrefslogtreecommitdiff
path: root/epan/geoip_db.c
diff options
context:
space:
mode:
authorDario Lombardo <lomato@gmail.com>2016-12-21 11:50:47 +0100
committerMichael Mann <mmann78@netscape.net>2017-01-12 12:39:15 +0000
commit805ddd1addbea96308fe3b790043ec511c73bbfa (patch)
treefbb2f6b1ee81a849e1afd5cac1f180601d9c7273 /epan/geoip_db.c
parent01c8028add4099ad8707302efd9207b82daa7f81 (diff)
downloadwireshark-805ddd1addbea96308fe3b790043ec511c73bbfa.tar.gz
uat: add a reset callback.
This function will free the resources allocated by the caller. Change-Id: Ib486c14e4fd3c321662fb71f7fd06733ce9a64a4 Reviewed-on: https://code.wireshark.org/review/19375 Reviewed-by: Peter Wu <peter@lekensteyn.nl> Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/geoip_db.c')
-rw-r--r--epan/geoip_db.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/epan/geoip_db.c b/epan/geoip_db.c
index 3be70713a2..f972ea0a4b 100644
--- a/epan/geoip_db.c
+++ b/epan/geoip_db.c
@@ -142,9 +142,7 @@ static void geoip_db_path_free_cb(void* p) {
g_free(m->path);
}
-/* called every time the user presses "Apply" or "OK in the list of
- * GeoIP directories, and also once on startup */
-static void geoip_db_post_update_cb(void) {
+static void geoip_dat_cleanup(void) {
GeoIP *gi;
guint i;
@@ -172,7 +170,17 @@ static void geoip_db_post_update_cb(void) {
}
/* finally, free the array itself */
g_array_free(geoip_dat_arr, TRUE);
+ geoip_dat_arr = NULL;
}
+}
+
+/* called every time the user presses "Apply" or "OK in the list of
+ * GeoIP directories, and also once on startup */
+static void geoip_db_post_update_cb(void) {
+ guint i;
+ GeoIP* gi;
+
+ geoip_dat_cleanup();
/* allocate the array */
geoip_dat_arr = g_array_new(FALSE, FALSE, sizeof(GeoIP *));
@@ -203,6 +211,11 @@ static void geoip_db_post_update_cb(void) {
g_array_append_val(geoip_dat_arr, gi);
}
+static void geoip_db_cleanup(void)
+{
+ geoip_dat_cleanup();
+}
+
/**
* Initialize GeoIP lookups
*/
@@ -228,6 +241,7 @@ geoip_db_pref_init(module_t *nameres)
NULL,
geoip_db_path_free_cb,
geoip_db_post_update_cb,
+ geoip_db_cleanup,
geoip_db_paths_fields);
prefs_register_uat_preference(nameres,