[gnome-settings-daemon] keyboard: Plug a memory leak when checking installed schemas
- From: Rui Matos <rtcm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-settings-daemon] keyboard: Plug a memory leak when checking installed schemas
- Date: Mon, 7 Sep 2015 14:43:17 +0000 (UTC)
commit 7eabee705df7230643dee245b438d3aaa19d442b
Author: Rui Matos <tiagomatos gmail com>
Date: Mon Sep 7 15:23:35 2015 +0200
keyboard: Plug a memory leak when checking installed schemas
g_settings_schema_source_list_schemas() returns allocated string
arrays that must be freed.
https://bugzilla.gnome.org/show_bug.cgi?id=754681
plugins/keyboard/gsd-keyboard-manager.c | 23 ++++++++---------------
1 files changed, 8 insertions(+), 15 deletions(-)
---
diff --git a/plugins/keyboard/gsd-keyboard-manager.c b/plugins/keyboard/gsd-keyboard-manager.c
index e7117c2..eb75c92 100644
--- a/plugins/keyboard/gsd-keyboard-manager.c
+++ b/plugins/keyboard/gsd-keyboard-manager.c
@@ -122,24 +122,12 @@ init_builder_with_sources (GVariantBuilder *builder,
}
static gboolean
-contained (char **items,
- const char *item)
-{
- while (*items) {
- if (g_strcmp0 (*items++, item) == 0) {
- return TRUE;
- }
- }
-
- return FALSE;
-}
-
-static gboolean
schema_is_installed (const char *schema)
{
GSettingsSchemaSource *source = NULL;
gchar **non_relocatable = NULL;
gchar **relocatable = NULL;
+ gboolean installed = FALSE;
source = g_settings_schema_source_get_default ();
if (!source)
@@ -147,8 +135,13 @@ schema_is_installed (const char *schema)
g_settings_schema_source_list_schemas (source, TRUE, &non_relocatable, &relocatable);
- return (contained (non_relocatable, schema) ||
- contained (relocatable, schema));
+ if (g_strv_contains ((const gchar * const *)non_relocatable, schema) ||
+ g_strv_contains ((const gchar * const *)relocatable, schema))
+ installed = TRUE;
+
+ g_strfreev (non_relocatable);
+ g_strfreev (relocatable);
+ return installed;
}
static gboolean
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]