[glib/param-value-default: 2/4] Constify g_param_value_defaults() argument



commit 6ad799ac677ae241da8b32ecf33b5cc9dc1d30bc
Author: Emmanuele Bassi <ebassi gnome org>
Date:   Sat Oct 26 14:03:16 2019 +0100

    Constify g_param_value_defaults() argument
    
    The GValue we pass in is supposed to not be modified by the GParamSpec.

 gobject/gparam.c | 5 ++---
 gobject/gparam.h | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)
---
diff --git a/gobject/gparam.c b/gobject/gparam.c
index 17df8316b..1158cddb7 100644
--- a/gobject/gparam.c
+++ b/gobject/gparam.c
@@ -630,8 +630,8 @@ g_param_value_set_default (GParamSpec *pspec,
  * Returns: whether @value contains the canonical default for this @pspec
  */
 gboolean
-g_param_value_defaults (GParamSpec *pspec,
-                       GValue     *value)
+g_param_value_defaults (GParamSpec   *pspec,
+                       const GValue *value)
 {
   GValue dflt_value = G_VALUE_INIT;
   gboolean defaults;
@@ -640,7 +640,6 @@ g_param_value_defaults (GParamSpec *pspec,
   g_return_val_if_fail (G_IS_VALUE (value), FALSE);
   g_return_val_if_fail (PSPEC_APPLIES_TO_VALUE (pspec, value), FALSE);
 
-  g_value_init (&dflt_value, G_PARAM_SPEC_VALUE_TYPE (pspec));
   G_PARAM_SPEC_GET_CLASS (pspec)->value_set_default (pspec, &dflt_value);
   defaults = G_PARAM_SPEC_GET_CLASS (pspec)->values_cmp (pspec, value, &dflt_value) == 0;
   g_value_unset (&dflt_value);
diff --git a/gobject/gparam.h b/gobject/gparam.h
index 33f95f0c5..b6a554653 100644
--- a/gobject/gparam.h
+++ b/gobject/gparam.h
@@ -307,7 +307,7 @@ void                g_param_value_set_default       (GParamSpec    *pspec,
                                                 GValue        *value);
 GLIB_AVAILABLE_IN_ALL
 gboolean       g_param_value_defaults          (GParamSpec    *pspec,
-                                                GValue        *value);
+                                                const GValue  *value);
 GLIB_AVAILABLE_IN_ALL
 gboolean       g_param_value_validate          (GParamSpec    *pspec,
                                                 GValue        *value);


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