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 /color_filters.c | |
parent | 0da877169b30c9141442d4931d6e2031802ce40c (diff) |
fix the memory leak problem mentioned lately by adding and using color_filters_cleanup()
svn path=/trunk/; revision=19422
Diffstat (limited to 'color_filters.c')
-rw-r--r-- | color_filters.c | 29 |
1 files changed, 16 insertions, 13 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 */ |