[libgda] GdaStatement: set 'structure' as GBoxed



commit 4cd114bd13cecb53cb20a9b94b23b21e10c6f0ae
Author: Daniel Espinosa <esodan gmail com>
Date:   Fri Apr 19 13:42:53 2019 -0500

    GdaStatement: set 'structure' as GBoxed
    
    GdaSqlStatement: use G_BOXED_DEFINE
    
    Fix memory leaks

 libgda/gda-statement.c                   |  6 +++---
 libgda/gda-util.c                        |  1 +
 libgda/sql-parser/gda-statement-struct.c | 12 +-----------
 3 files changed, 5 insertions(+), 14 deletions(-)
---
diff --git a/libgda/gda-statement.c b/libgda/gda-statement.c
index 23d206ddd..63d289138 100644
--- a/libgda/gda-statement.c
+++ b/libgda/gda-statement.c
@@ -139,7 +139,7 @@ gda_statement_class_init (GdaStatementClass * klass)
        object_class->set_property = gda_statement_set_property;
        object_class->get_property = gda_statement_get_property;
        g_object_class_install_property (object_class, PROP_STRUCTURE,
-                                        g_param_spec_pointer ("structure", NULL, NULL, 
+                                        g_param_spec_boxed ("structure", NULL, NULL, GDA_TYPE_SQL_STATEMENT,
                                                               G_PARAM_WRITABLE | G_PARAM_READABLE));
 }
 
@@ -238,7 +238,7 @@ gda_statement_set_property (GObject *object,
                                g_free (priv->requested_types);
                                priv->requested_types = NULL;
                        }
-                       priv->internal_struct = gda_sql_statement_copy (g_value_get_pointer (value));
+                       priv->internal_struct = g_value_dup_boxed (value);
                        g_signal_emit (stmt, gda_statement_signals [RESET], 0);
                        break;
                default:
@@ -259,7 +259,7 @@ gda_statement_get_property (GObject *object,
 
        switch (param_id) {
                case PROP_STRUCTURE:
-                       g_value_set_pointer (value, gda_sql_statement_copy (priv->internal_struct));
+                       g_value_set_boxed (value, priv->internal_struct);
                        break;
                default:
                        G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
diff --git a/libgda/gda-util.c b/libgda/gda-util.c
index d2fd8904f..b22f96d24 100644
--- a/libgda/gda-util.c
+++ b/libgda/gda-util.c
@@ -1648,6 +1648,7 @@ gda_rewrite_statement_for_null_parameters (GdaStatement *stmt, GdaSet *params,
                return mod;
        }
        else {
+               gda_sql_statement_free (sqlst);
                /* error => leave *out_stmt to %NULL */
                return TRUE;
        }
diff --git a/libgda/sql-parser/gda-statement-struct.c b/libgda/sql-parser/gda-statement-struct.c
index aaeda892c..cabac26d0 100644
--- a/libgda/sql-parser/gda-statement-struct.c
+++ b/libgda/sql-parser/gda-statement-struct.c
@@ -100,17 +100,7 @@ gda_sql_statement_get_contents_infos  (GdaSqlStatementType type)
        return contents[type];
 }
 
-GType
-gda_sql_statement_get_type (void)
-{
-       static GType our_type = 0;
-
-       if (our_type == 0)
-               our_type = g_boxed_type_register_static ("GdaSqlStatement",
-                       (GBoxedCopyFunc) gda_sql_statement_copy,
-                       (GBoxedFreeFunc) gda_sql_statement_free);
-       return our_type;
-}
+G_DEFINE_BOXED_TYPE(GdaSqlStatement, gda_sql_statement, gda_sql_statement_copy, gda_sql_statement_free)
 
 /**
  * gda_sql_statement_new


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