[glib: 2/6] gsettings: Clarify ownership transfer in a few places
- From: Simon McVittie <smcv src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/6] gsettings: Clarify ownership transfer in a few places
- Date: Wed, 30 Jan 2019 18:56:49 +0000 (UTC)
commit f829b65e518a82bd8cb350bb576bcfd6186c3064
Author: Philip Withnall <withnall endlessm com>
Date: Wed Jan 23 15:15:53 2019 +0000
gsettings: Clarify ownership transfer in a few places
I was trying to debug some memory leaks in the gsettings test.
Eventually, it seems that actually they’re caused by the
GMemorySettingsBackend being cached by GIOModule — so this commit makes
no functional changes. It should make the code and documentation a bit
clearer though.
Signed-off-by: Philip Withnall <withnall endlessm com>
gio/gsettings.c | 8 +++++---
gio/gsettingsbackend.c | 2 ++
gio/gsettingsschema.c | 2 ++
3 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/gio/gsettings.c b/gio/gsettings.c
index 2934f2b4b..dd8f94485 100644
--- a/gio/gsettings.c
+++ b/gio/gsettings.c
@@ -1137,6 +1137,8 @@ g_settings_new_full (GSettingsSchema *schema,
}
/* Internal read/write utilities {{{1 */
+
+/* @value will be sunk */
static gboolean
g_settings_write_to_backend (GSettings *settings,
GSettingsSchemaKey *key,
@@ -1417,7 +1419,7 @@ g_settings_set_enum (GSettings *settings,
return FALSE;
}
- success = g_settings_write_to_backend (settings, &skey, variant);
+ success = g_settings_write_to_backend (settings, &skey, g_steal_pointer (&variant));
g_settings_schema_key_clear (&skey);
return success;
@@ -1528,7 +1530,7 @@ g_settings_set_flags (GSettings *settings,
return FALSE;
}
- success = g_settings_write_to_backend (settings, &skey, variant);
+ success = g_settings_write_to_backend (settings, &skey, g_steal_pointer (&variant));
g_settings_schema_key_clear (&skey);
return success;
@@ -1672,7 +1674,7 @@ g_settings_set (GSettings *settings,
value = g_variant_new_va (format, NULL, &ap);
va_end (ap);
- return g_settings_set_value (settings, key, value);
+ return g_settings_set_value (settings, key, g_steal_pointer (&value));
}
/**
diff --git a/gio/gsettingsbackend.c b/gio/gsettingsbackend.c
index edc4ff4d3..ca9b908a5 100644
--- a/gio/gsettingsbackend.c
+++ b/gio/gsettingsbackend.c
@@ -777,6 +777,8 @@ g_settings_backend_read_user_value (GSettingsBackend *backend,
* to indicate that the affected keys have suddenly "changed back" to their
* old values.
*
+ * If @value has a floating reference, it will be sunk.
+ *
* Returns: %TRUE if the write succeeded, %FALSE if the key was not writable
*/
gboolean
diff --git a/gio/gsettingsschema.c b/gio/gsettingsschema.c
index 38c9d78b9..60b3fe0b3 100644
--- a/gio/gsettingsschema.c
+++ b/gio/gsettingsschema.c
@@ -1472,6 +1472,7 @@ g_settings_schema_key_to_enum (GSettingsSchemaKey *key,
return result;
}
+/* Returns a new floating #GVariant. */
GVariant *
g_settings_schema_key_from_enum (GSettingsSchemaKey *key,
gint value)
@@ -1511,6 +1512,7 @@ g_settings_schema_key_to_flags (GSettingsSchemaKey *key,
return result;
}
+/* Returns a new floating #GVariant. */
GVariant *
g_settings_schema_key_from_flags (GSettingsSchemaKey *key,
guint value)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]