[libgda] GdaTime: fix memory leaks



commit e24851fa7832552d76a5816ff61610d8aa24dc68
Author: Daniel Espinosa <esodan gmail com>
Date:   Fri Jan 31 09:03:16 2020 -0600

    GdaTime: fix memory leaks

 libgda/gda-data-model.c |  2 +-
 libgda/gda-value.c      | 36 +++++++++++++++++++-----------------
 2 files changed, 20 insertions(+), 18 deletions(-)
---
diff --git a/libgda/gda-data-model.c b/libgda/gda-data-model.c
index 16a50200c..e07587724 100644
--- a/libgda/gda-data-model.c
+++ b/libgda/gda-data-model.c
@@ -1534,7 +1534,7 @@ export_to_text_separated (GdaDataModel *model, const gint *cols, gint nb_cols,
                                }
                                else if (g_type_is_a (G_VALUE_TYPE (value), GDA_TYPE_TIME)) {
                                        const GdaTime *tim = gda_value_get_time (value);
-                                       if (! gda_time_valid (tim))
+                                       if (tim != NULL)
                                                value = NULL;                                   
                                }
                                else if (g_type_is_a (G_VALUE_TYPE (value), G_TYPE_DATE_TIME)) {
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index 79a76ee50..fe57ae658 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -1673,11 +1673,11 @@ void
 gda_time_set_hour (GdaTime* time, gushort hour)
 {
        g_return_if_fail (time != NULL);
-       gda_time_new_from_values (hour,
-                                 gda_time_get_minute (time),
-                                 gda_time_get_second (time),
-                                 gda_time_get_fraction (time),
-                                 gda_time_get_timezone (time));
+       time = gda_time_new_from_values (hour,
+                                         gda_time_get_minute (time),
+                                         gda_time_get_second (time),
+                                         gda_time_get_fraction (time),
+                                         gda_time_get_timezone (time));
 }
 /**
  * gda_time_get_minute:
@@ -1702,11 +1702,11 @@ void
 gda_time_set_minute (GdaTime* time, gushort minute)
 {
        g_return_if_fail (time != NULL);
-       gda_time_new_from_values (gda_time_get_hour (time),
-                                 minute,
-                                 gda_time_get_second (time),
-                                 gda_time_get_fraction (time),
-                                 gda_time_get_timezone (time));
+       time = gda_time_new_from_values (gda_time_get_hour (time),
+                                         minute,
+                                         gda_time_get_second (time),
+                                         gda_time_get_fraction (time),
+                                         gda_time_get_timezone (time));
 }
 /**
  * gda_time_get_second:
@@ -1731,11 +1731,11 @@ void
 gda_time_set_second (GdaTime* time, gushort second)
 {
        g_return_if_fail (time != NULL);
-       gda_time_new_from_values (gda_time_get_hour (time),
-                                 gda_time_get_minute (time),
-                                 second,
-                                 gda_time_get_fraction (time),
-                                 gda_time_get_timezone (time));
+       time = gda_time_new_from_values (gda_time_get_hour (time),
+                                         gda_time_get_minute (time),
+                                         second,
+                                         gda_time_get_fraction (time),
+                                         gda_time_get_timezone (time));
 }
 /**
  * gda_time_get_fraction:
@@ -1767,7 +1767,7 @@ void
 gda_time_set_fraction (GdaTime* time, gulong fraction)
 {
        g_return_if_fail (time != NULL);
-       gda_time_new_from_values (gda_time_get_hour (time),
+       time = gda_time_new_from_values (gda_time_get_hour (time),
                                  gda_time_get_minute (time),
                                  gda_time_get_second (time),
                                  fraction,
@@ -1815,7 +1815,7 @@ void
 gda_time_set_timezone (GdaTime* time, glong timezone)
 {
        g_return_if_fail (time != NULL);
-       gda_time_new_from_values (gda_time_get_hour (time),
+       time = gda_time_new_from_values (gda_time_get_hour (time),
                                  gda_time_get_minute (time),
                                  gda_time_get_second (time),
                                  gda_time_get_fraction (time),
@@ -1826,6 +1826,8 @@ gda_time_set_timezone (GdaTime* time, glong timezone)
  * gda_time_valid:
  * @time: a #GdaTime value to check if it is valid
  *
+ * A time is always valid, so this method has been deprecated.
+ *
  * Returns: #TRUE if #GdaTime is valid; %FALSE otherwise.
  *
  * Deprecated: 6.0


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