diff options
author | Ulf Lamping <ulf.lamping@web.de> | 2006-10-03 23:24:48 +0000 |
---|---|---|
committer | Ulf Lamping <ulf.lamping@web.de> | 2006-10-03 23:24:48 +0000 |
commit | 7a7b422fa93045a875e11dd0a8829754e6208ac9 (patch) | |
tree | db336e5c9326f8a93c5c0d030154488c59acea8b | |
parent | 0da877169b30c9141442d4931d6e2031802ce40c (diff) |
fix the memory leak problem mentioned lately by adding and using color_filters_cleanup()
svn path=/trunk/; revision=19422
-rw-r--r-- | color_filters.c | 29 | ||||
-rw-r--r-- | color_filters.h | 3 | ||||
-rw-r--r-- | file.c | 2 |
3 files changed, 20 insertions, 14 deletions
diff --git a/color_filters.c b/color_filters.c index c8183513d4..1cf34806f0 100644 --- a/color_filters.c +++ b/color_filters.c @@ -46,9 +46,13 @@ static gboolean read_users_filters(GSList **cfl); - +/* the currently active filters */ static GSList *color_filter_list = NULL; +/* keep "old" deleted filters in this list until + * the dissection no longer needs them (e.g. file is closed) */ +static GSList *color_filter_deleted_list = NULL; + /* Color Filters can en-/disabled. */ gboolean filters_enabled = TRUE; @@ -146,7 +150,7 @@ color_filter_list_clone(GSList *cfl) void color_filters_init(void) { - /* delete all existing filters */ + /* delete all currently existing filters */ color_filter_list_delete(&color_filter_list); /* try to read the users filters */ @@ -155,6 +159,13 @@ color_filters_init(void) color_filters_read_globals(&color_filter_list); } +void +color_filters_cleanup(void) +{ + /* delete the previously deleted filters */ + color_filter_list_delete(&color_filter_deleted_list); +} + static void color_filters_clone_cb(gpointer filter_arg, gpointer user_data) { @@ -189,17 +200,9 @@ color_filter_compile_cb(gpointer filter_arg, gpointer *cfl) void color_filters_apply(GSList *cfl) { - /* remove "old" entries */ -/* color_filter_list_delete(&color_filter_list);*/ - - /* deleting the color filters crashes unpredictably - * (e.g. sometimes while clearing the list) :-( - * - * for now, just clear the list and let the filters remain in memory - * until WS is closed -> memory leak - * - * XXX - move the filters to a "removed list" as before - * and delete them if the file is closed (or on rescan of packets or such?) */ + /* "move" old entries to the deleted list + * we must keep them until the dissection no longer needs them */ + color_filter_deleted_list = g_slist_concat(color_filter_deleted_list, color_filter_list); color_filter_list = NULL; /* clone all list entries from edit to normal list */ diff --git a/color_filters.h b/color_filters.h index b9b7d788b8..beceea5ea2 100644 --- a/color_filters.h +++ b/color_filters.h @@ -48,7 +48,8 @@ typedef struct _color_filter { /** Init the color filters (incl. initial read from file). */ void color_filters_init(void); - +/** Cleanup remaining color filter zombies */ +void color_filters_cleanup(void); /** Color filters currently used? * @@ -347,6 +347,8 @@ cf_close(capture_file *cf) /* close things, if not already closed before */ if(cf->state != FILE_CLOSED) { + color_filters_cleanup(); + cf_reset_state(cf); cleanup_dissection(); |