Fix leaks related to recent settings
Fix leaks related to recent settings reported by Valgrind simply after starting/stopping application. Bug: 14071 Change-Id: Ib4f205218945c8776724899c0dd99cc81b79a41d Reviewed-on: https://code.wireshark.org/review/23599 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
8f4692f6f9
commit
3ce30eb1fd
31
ui/recent.c
31
ui/recent.c
|
@ -121,16 +121,17 @@ static const value_string ts_seconds_values[] = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static void
|
static void
|
||||||
free_col_width_info(recent_settings_t *rs)
|
free_col_width_data(gpointer data, gpointer user_data _U_)
|
||||||
{
|
{
|
||||||
col_width_data *cfmt;
|
col_width_data *cfmt = (col_width_data *)data;
|
||||||
|
|
||||||
while (rs->col_width_list != NULL) {
|
|
||||||
cfmt = (col_width_data *)rs->col_width_list->data;
|
|
||||||
g_free(cfmt->cfield);
|
g_free(cfmt->cfield);
|
||||||
g_free(cfmt);
|
g_free(cfmt);
|
||||||
rs->col_width_list = g_list_remove_link(rs->col_width_list, rs->col_width_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
free_col_width_info(recent_settings_t *rs)
|
||||||
|
{
|
||||||
|
g_list_foreach(rs->col_width_list, free_col_width_data, NULL);
|
||||||
g_list_free(rs->col_width_list);
|
g_list_free(rs->col_width_list);
|
||||||
rs->col_width_list = NULL;
|
rs->col_width_list = NULL;
|
||||||
}
|
}
|
||||||
|
@ -1524,6 +1525,24 @@ recent_set_column_xalign(gint col, gchar xalign)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
recent_init(void)
|
||||||
|
{
|
||||||
|
memset(&recent, 0, sizeof(recent_settings_t));
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
recent_cleanup(void)
|
||||||
|
{
|
||||||
|
free_col_width_info(&recent);
|
||||||
|
g_free(recent.gui_fileopen_remembered_dir);
|
||||||
|
g_list_free_full(recent.gui_additional_toolbars, g_free);
|
||||||
|
g_list_free_full(recent.interface_toolbars, g_free);
|
||||||
|
prefs_clear_string_list(recent.conversation_tabs);
|
||||||
|
prefs_clear_string_list(recent.endpoint_tabs);
|
||||||
|
prefs_clear_string_list(recent.custom_colors);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
* Editor modelines - http://www.wireshark.org/tools/modelines.html
|
||||||
*
|
*
|
||||||
|
|
|
@ -117,6 +117,12 @@ typedef struct recent_settings_tag {
|
||||||
/** Global recent settings. */
|
/** Global recent settings. */
|
||||||
extern recent_settings_t recent;
|
extern recent_settings_t recent;
|
||||||
|
|
||||||
|
/** Initialize recent settings module (done at startup) */
|
||||||
|
extern void recent_init(void);
|
||||||
|
|
||||||
|
/** Cleanup/Frees recent settings (done at shutdown) */
|
||||||
|
extern void recent_cleanup(void);
|
||||||
|
|
||||||
/** Write recent settings file.
|
/** Write recent settings file.
|
||||||
*
|
*
|
||||||
* @return TRUE if succeeded, FALSE if failed
|
* @return TRUE if succeeded, FALSE if failed
|
||||||
|
|
|
@ -487,6 +487,7 @@ int main(int argc, char *qt_argv[])
|
||||||
}
|
}
|
||||||
|
|
||||||
profile_store_persconffiles(TRUE);
|
profile_store_persconffiles(TRUE);
|
||||||
|
recent_init();
|
||||||
|
|
||||||
/* Read the profile independent recent file. We have to do this here so we can */
|
/* Read the profile independent recent file. We have to do this here so we can */
|
||||||
/* set the profile before it can be set from the command line parameter */
|
/* set the profile before it can be set from the command line parameter */
|
||||||
|
@ -938,6 +939,7 @@ int main(int argc, char *qt_argv[])
|
||||||
|
|
||||||
ret_val = wsApp->exec();
|
ret_val = wsApp->exec();
|
||||||
|
|
||||||
|
recent_cleanup();
|
||||||
epan_cleanup();
|
epan_cleanup();
|
||||||
|
|
||||||
#ifdef HAVE_EXTCAP
|
#ifdef HAVE_EXTCAP
|
||||||
|
|
Loading…
Reference in New Issue