[geany/geany] 5868c6: Fix leaks upon symbol list updating

Colomban Wendling git-noreply at xxxxx
Mon Apr 22 18:20:53 UTC 2013


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Mon, 22 Apr 2013 18:20:53 UTC
Commit:      5868c6991c74ce75991c73748b85fa83774141bc
             https://github.com/geany/geany/commit/5868c6991c74ce75991c73748b85fa83774141bc

Log Message:
-----------
Fix leaks upon symbol list updating


Modified Paths:
--------------
    src/symbols.c

Modified: src/symbols.c
17 files changed, 16 insertions(+), 1 deletions(-)
===================================================================
@@ -1384,6 +1384,21 @@ static void tags_table_remove(GHashTable *table, TMTag *tag)
 }
 
 
+static void tags_table_destroy(GHashTable *table)
+{
+	/* free any leftover elements.  note that we can't register a value_free_func when
+	 * creating the hash table because we only want to free it when destroying the table,
+	 * not when inserting a duplicate (we handle this manually) */
+	GHashTableIter iter;
+	gpointer value;
+
+	g_hash_table_iter_init(&iter, table);
+	while (g_hash_table_iter_next(&iter, NULL, &value))
+		g_list_free(value);
+	g_hash_table_destroy(table);
+}
+
+
 /*
  * Updates the tag tree for a document with the tags in *list.
  * @param doc a document
@@ -1562,7 +1577,7 @@ static void update_tree_tags(GeanyDocument *doc, GList **tags)
 	}
 
 	g_hash_table_destroy(parents_table);
-	g_hash_table_destroy(tags_table);
+	tags_table_destroy(tags_table);
 }
 
 



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Commits mailing list