[glib/new-gsettings] Add g_return_if_fail()s to g_variant_new_from_data()



commit 09086935d3de63e91ddeb79f9dc41cc6b3a5d290
Author: Ryan Lortie <desrt desrt ca>
Date:   Sat Apr 10 22:01:02 2010 -0400

    Add g_return_if_fail()s to g_variant_new_from_data()
    
    also, document that @type must be definite

 glib/gvariant.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
---
diff --git a/glib/gvariant.c b/glib/gvariant.c
index 721740f..f8f29e0 100644
--- a/glib/gvariant.c
+++ b/glib/gvariant.c
@@ -4087,7 +4087,7 @@ g_variant_byteswap (GVariant *value)
 
 /**
  * g_variant_new_from_data:
- * @type: a #GVariantType
+ * @type: a definite #GVariantType
  * @data: the serialised data
  * @size: the size of @data
  * @trusted: %TRUE if @data is definitely in normal form
@@ -4129,6 +4129,9 @@ g_variant_new_from_data (const GVariantType *type,
   GVariant *value;
   GBuffer *buffer;
 
+  g_return_val_if_fail (g_variant_type_is_definite (type), NULL);
+  g_return_val_if_fail (data != NULL || size == 0, NULL);
+
   if (notify)
     buffer = g_buffer_new_from_pointer (data, size, notify, user_data);
   else



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]