Le 19/12/2010 16:05, Colomban Wendling a écrit : > [...] > > Well! If you apply all these patches, you should have a working, > real-time, in-memory tag parsing that should look good :) > > So, what's left? Testing of course, lot of it. > Also, for now it doesn't update tag list before the first save (for new > documents). I've not investigating the issue yet though. > > > So I'll stop here, thank you for your time reading and let you test > this, right? :) I found a few days ago that one of my patches (0006-Provide-a-GType-for-TMTag-and-use-it.patch) introduced 3 quite big memory leaks (some TMTags references never released). Here's the fix (0001-Fix-leaking-tags-when-fetching-them-from-the-symbols-model-.patch). I strongly recommend to any user of my previous patches to apply this one, because the leak can become really visible when working with files with many tags.
Also, while at it I found a small leak in the C tag parser, also joined the fix (0001-Plug-a-memory-leak-in-the-C-tag-parser.patch). This one probably also applies alone. All these patches may get a little confusing with time, so if a summary mail would be appreciated, I can do it :) Regards, Colomban
>From b115b398ae8d622425c3c8cd667693f370a3ba93 Mon Sep 17 00:00:00 2001 From: Colomban Wendling <[email protected]> Date: Mon, 14 Feb 2011 20:03:20 +0100 Subject: [PATCH] Fix leaking tags when fetching them from the symbol's model (bug introduced in d9a50d9) --- src/sidebar.c | 1 + src/symbols.c | 35 ++++++++++++++++++++--------------- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/sidebar.c b/src/sidebar.c index 4509eab..892cbc5 100644 --- a/src/sidebar.c +++ b/src/sidebar.c @@ -886,6 +886,7 @@ static gboolean on_taglist_tree_selection_changed(gpointer data) change_focus_to_editor(doc, NULL); } } + tm_tag_unref(tag); } return FALSE; } diff --git a/src/symbols.c b/src/symbols.c index 2369a00..afe0f23 100644 --- a/src/symbols.c +++ b/src/symbols.c @@ -1320,7 +1320,8 @@ static gint tree_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer user_data) { gboolean sort_by_name = GPOINTER_TO_INT(user_data); - const TMTag *tag_a, *tag_b; + TMTag *tag_a, *tag_b; + gint cmp; gtk_tree_model_get(model, a, SYMBOLS_COLUMN_TAG, &tag_a, -1); gtk_tree_model_get(model, b, SYMBOLS_COLUMN_TAG, &tag_b, -1); @@ -1330,13 +1331,12 @@ static gint tree_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, if (tag_a && !tag_has_missing_parent(tag_a, GTK_TREE_STORE(model), a) && tag_b && !tag_has_missing_parent(tag_b, GTK_TREE_STORE(model), b)) { - return sort_by_name ? compare_symbol(tag_a, tag_b) : + cmp = sort_by_name ? compare_symbol(tag_a, tag_b) : compare_symbol_lines(tag_a, tag_b); } else { gchar *astr, *bstr; - gint cmp; gtk_tree_model_get(model, a, SYMBOLS_COLUMN_NAME, &astr, -1); gtk_tree_model_get(model, b, SYMBOLS_COLUMN_NAME, &bstr, -1); @@ -1350,23 +1350,28 @@ static gint tree_sort_func(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, { /* this is what g_strcmp0() does */ if (! astr) - return -(astr != bstr); + cmp = -(astr != bstr); if (! bstr) - return astr != bstr; - - cmp = strcmp(astr, bstr); - - /* sort duplicate 'ScopeName::OverloadedTagName' items by line as well */ - if (tag_a && tag_b) - if (!sort_by_name || - (utils_str_equal(tag_a->name, tag_b->name) && - utils_str_equal(tag_a->atts.entry.scope, tag_b->atts.entry.scope))) - cmp = compare_symbol_lines(tag_a, tag_b); + cmp = astr != bstr; + else + { + cmp = strcmp(astr, bstr); + + /* sort duplicate 'ScopeName::OverloadedTagName' items by line as well */ + if (tag_a && tag_b) + if (!sort_by_name || + (utils_str_equal(tag_a->name, tag_b->name) && + utils_str_equal(tag_a->atts.entry.scope, tag_b->atts.entry.scope))) + cmp = compare_symbol_lines(tag_a, tag_b); + } } g_free(astr); g_free(bstr); - return cmp; } + tm_tag_unref(tag_a); + tm_tag_unref(tag_b); + + return cmp; } -- 1.7.2.3
>From c4c5695cbfab67dff77b04e692004353ad89b0ce Mon Sep 17 00:00:00 2001 From: Colomban Wendling <[email protected]> Date: Mon, 14 Feb 2011 20:05:03 +0100 Subject: [PATCH] Plug a memory leak in the C tag parser --- tagmanager/c.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/tagmanager/c.c b/tagmanager/c.c index e7cb017..2d2352c 100644 --- a/tagmanager/c.c +++ b/tagmanager/c.c @@ -2891,6 +2891,7 @@ static void tagCheck (statementInfo *const st) else if (isContextualStatement (st)) { tokenInfo *name_token = (tokenInfo *)prev; + boolean free_name_token = FALSE; if (isType (name_token, TOKEN_NAME)) { @@ -2927,6 +2928,7 @@ static void tagCheck (statementInfo *const st) char buffer[64]; name_token = newToken (); + free_name_token = TRUE; copyToken (name_token, contextual_token); sprintf(buffer, "anon_%s_%d", name_token->name->buffer, contextual_fake_count++); @@ -2945,6 +2947,8 @@ static void tagCheck (statementInfo *const st) } } qualifyBlockTag (st, name_token); + if (free_name_token) + deleteToken (name_token); } break; } -- 1.7.2.3
_______________________________________________ Geany-devel mailing list [email protected] http://lists.uvena.de/cgi-bin/mailman/listinfo/geany-devel
