From f2cab560c64d15e8568a64d0f02f0a6b76d82a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jir=CC=8Ci=CC=81=20Techet?= Date: Fri, 6 Feb 2015 15:18:43 +0100 Subject: [PATCH 1/2] Eliminate some minor leaks Found using the Instruments XCode tool on OS X. --- src/highlighting.c | 2 ++ src/keyfile.c | 4 ++++ src/project.c | 3 ++- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/highlighting.c b/src/highlighting.c index 03846b1c9..2838c451c 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -577,7 +577,9 @@ static void styleset_common_init(GKeyFile *config, GKeyFile *config_home) get_keyfile_int(config, config_home, "styling", "line_height", 0, 0, &common_style_set.styling[GCS_LINE_HEIGHT]); + g_free(common_style_set.wordchars); get_keyfile_wordchars(config, config_home, &common_style_set.wordchars); + g_free(whitespace_chars); whitespace_chars = get_keyfile_whitespace_chars(config, config_home); } diff --git a/src/keyfile.c b/src/keyfile.c index 0fdcd2f1c..411f26e78 100644 --- a/src/keyfile.c +++ b/src/keyfile.c @@ -664,7 +664,11 @@ void configuration_load_session_files(GKeyFile *config, gboolean read_recent_fil /* the project may load another list than the main setting */ if (session_files != NULL) + { + foreach_ptr_array(tmp_array, i, session_files) + g_strfreev(tmp_array); g_ptr_array_free(session_files, TRUE); + } session_files = g_ptr_array_new(); have_session_files = TRUE; diff --git a/src/project.c b/src/project.c index b66e3aba6..202a8b062 100644 --- a/src/project.c +++ b/src/project.c @@ -440,6 +440,7 @@ static void destroy_project(gboolean open_default) g_free(app->project->description); g_free(app->project->file_name); g_free(app->project->base_path); + g_strfreev(app->project->file_patterns); g_free(app->project); app->project = NULL; @@ -813,7 +814,7 @@ static gboolean update_config(const PropertyDialogElements *e, gboolean new_proj buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(e->description)); gtk_text_buffer_get_start_iter(buffer, &start); gtk_text_buffer_get_end_iter(buffer, &end); - SETPTR(p->description, g_strdup(gtk_text_buffer_get_text(buffer, &start, &end, FALSE))); + SETPTR(p->description, gtk_text_buffer_get_text(buffer, &start, &end, FALSE)); foreach_slist(node, stash_groups) stash_group_update(node->data, e->dialog); From 709cbd512b26ce42134dcf9460f7ed570eb5afac Mon Sep 17 00:00:00 2001 From: Colomban Wendling Date: Wed, 4 Mar 2015 16:39:36 +0100 Subject: [PATCH 2/2] Explicitly initialize some variables for which we use the default value This does not change anything in practice because static variables are initialized implicitly as we need them anyway, but this makes things clearer and more explicit. --- src/highlighting.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/highlighting.c b/src/highlighting.c index 2838c451c..bbaf9b6f1 100644 --- a/src/highlighting.c +++ b/src/highlighting.c @@ -58,7 +58,7 @@ #define GEANY_WHITESPACE_CHARS " \t" "!\"#$%&'()*+,-./:;<=>?@[\\]^`{|}~" -static gchar *whitespace_chars; +static gchar *whitespace_chars = NULL; typedef struct @@ -112,7 +112,7 @@ static struct gint fold_draw_line; gchar *wordchars; -} common_style_set; +} common_style_set = { { { 0 } }, 0, 0, 0, NULL }; /* For filetypes.common [named_styles] section.