diff options
author | 2011-08-28 21:56:03 +0000 | |
---|---|---|
committer | 2011-08-28 21:56:03 +0000 | |
commit | 7396c19eb425bb47eaa51956fd8cfaae39fe8cc8 (patch) | |
tree | c68e0f97cf8dfaf869c52ea5f7c19d6c811fa145 /src/trg-prefs.c | |
parent | 217141e7fe29e5ccc9c9f39ab0402667cc4bec9f (diff) |
fix small memory leak when switching/deleting profiles
Diffstat (limited to 'src/trg-prefs.c')
-rw-r--r-- | src/trg-prefs.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/trg-prefs.c b/src/trg-prefs.c index 9c320cd..cc56944 100644 --- a/src/trg-prefs.c +++ b/src/trg-prefs.c @@ -222,19 +222,21 @@ void trg_prefs_set_string(TrgPrefs *p, gchar *key, const gchar *value, void trg_prefs_set_profile(TrgPrefs *p, JsonObject *profile) { TrgPrefsPrivate *priv = GET_PRIVATE(p); - JsonArray *profiles = trg_prefs_get_profiles(p); + GList *profiles = json_array_get_elements(trg_prefs_get_profiles(p)); priv->profile = profile; GList *li; gint i = 0; - for (li = json_array_get_elements(profiles); li; li = g_list_next(li)) { + for (li = profiles; li; li = g_list_next(li)) { if (json_node_get_object((JsonNode*) li->data) == profile) { trg_prefs_set_int(p, TRG_PREFS_KEY_PROFILE_ID, i, TRG_PREFS_GLOBAL); break; } i++; } + + g_list_free(profiles); } JsonObject *trg_prefs_new_profile(TrgPrefs *p) { @@ -245,13 +247,13 @@ JsonObject *trg_prefs_new_profile(TrgPrefs *p) { } void trg_prefs_del_profile(TrgPrefs *p, JsonObject *profile) { - JsonArray *profiles = trg_prefs_get_profiles(p); + GList *profiles = json_array_get_elements(trg_prefs_get_profiles(p)); GList *li; JsonNode *node; int i = 0; - for (li = json_array_get_elements(profiles); li; li = g_list_next(li)) { + for (li = profiles; li; li = g_list_next(li)) { node = (JsonNode*) li->data; if (profile == (gpointer) json_node_get_object(node)) { json_array_remove_element(profiles, i); @@ -259,6 +261,8 @@ void trg_prefs_del_profile(TrgPrefs *p, JsonObject *profile) { } i++; } + + g_list_free(profiles); } JsonObject* trg_prefs_get_profile(TrgPrefs *p) { |