diff options
author | Lubomir I. Ivanov <neolit123@gmail.com> | 2012-12-22 23:34:19 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-22 20:15:00 -0800 |
commit | b10ebbda618c010fabdd7bb05d07aa9d69ce1305 (patch) | |
tree | fc8e0898c19c10f4d5710744ce85b95665cb3c36 | |
parent | 50aa6d1afa38a3d71d9d699fbf9635aed34a6c14 (diff) | |
download | subsurface-b10ebbda618c010fabdd7bb05d07aa9d69ce1305.tar.gz |
Fix some small memory leaks related to gtk_tree_model_get_path()
From the GTK docs on gtk_tree_model_get_path():
"Returns a newly-created GtkTreePath referenced by iter.
This path should be freed with gtk_tree_path_free()."
Signed-off-by: Lubomir I. Ivanov <neolit123@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | divelist.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/divelist.c b/divelist.c index 45091e02b..16e0eaf3e 100644 --- a/divelist.c +++ b/divelist.c @@ -131,11 +131,14 @@ static void first_leaf(GtkTreeModel *model, GtkTreeIter *iter, int *diveidx) while (*diveidx < 0) { memcpy(&parent, iter, sizeof(parent)); tpath = gtk_tree_model_get_path(model, &parent); - if (!gtk_tree_model_iter_children(model, iter, &parent)) + if (!gtk_tree_model_iter_children(model, iter, &parent)) { /* we should never have a parent without child */ + gtk_tree_path_free(tpath); return; + } if(!gtk_tree_view_row_expanded(GTK_TREE_VIEW(dive_list.tree_view), tpath)) gtk_tree_view_expand_row(GTK_TREE_VIEW(dive_list.tree_view), tpath, FALSE); + gtk_tree_path_free(tpath); gtk_tree_model_get(model, iter, DIVE_INDEX, diveidx, -1); } } @@ -1644,6 +1647,7 @@ static void turn_dive_into_trip(GtkTreePath *path) newiter = move_dive_between_trips(&iter, NULL, &newparent, NULL, FALSE); treepath = gtk_tree_model_get_path(MODEL(dive_list), newiter); gtk_tree_view_expand_to_path(GTK_TREE_VIEW(dive_list.tree_view), treepath); + gtk_tree_path_free(treepath); dive = get_dive(idx); create_and_hookup_trip_from_dive(dive); free(newiter); @@ -1688,13 +1692,17 @@ static void insert_trip_before(GtkTreePath *path) dive = get_dive(idx); add_dive_to_trip(dive, new_divetrip); free(move_dive_between_trips(&nextsibling, &parent, &newparent, NULL, FALSE)); - if (gtk_tree_path_compare(path, treepath) == 0) + if (gtk_tree_path_compare(path, treepath) == 0) { /* we copied the dive we were called with; we are done */ + gtk_tree_path_free(treepath); break; + } + gtk_tree_path_free(treepath); } /* treat this divetrip as if it had been read from a file */ treepath = gtk_tree_model_get_path(MODEL(dive_list), &newparent); gtk_tree_view_expand_to_path(GTK_TREE_VIEW(dive_list.tree_view), treepath); + gtk_tree_path_free(treepath); #ifdef DEBUG_TRIP dump_trip_list(); #endif @@ -1978,6 +1986,7 @@ void remember_tree_state() if (trip) trip->expanded = TRUE; } + gtk_tree_path_free(path); } while (gtk_tree_model_iter_next(TREEMODEL(dive_list), &iter)); } |