[libgda] GdaMetaStore: Fix memory leak at db objects creation



commit b79575016b6328cd34b433136b9b76306d81b549
Author: Daniel Espinosa <esodan gmail com>
Date:   Wed Apr 24 17:11:36 2019 -0500

    GdaMetaStore: Fix memory leak at db objects creation

 libgda/gda-meta-store.c | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)
---
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index 82f43db01..69b8b7b26 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -619,6 +619,8 @@ typedef struct {
 
 static guint ProviderSpecific_hash (gconstpointer key);
 static gboolean ProviderSpecific_equal (gconstpointer a, gconstpointer b);
+static void provider_specific_key_free (ProviderSpecificKey *key);
+static void provider_specific_value_free (ProviderSpecificValue *val);
 
 typedef struct {
        GdaConnection *cnc;
@@ -723,6 +725,19 @@ ProviderSpecific_equal (gconstpointer a, gconstpointer b)
                return TRUE;
 }
 
+static void
+provider_specific_key_free (ProviderSpecificKey *key)
+{
+  g_free (key->expr);
+  g_free (key);
+}
+static void
+provider_specific_value_free (ProviderSpecificValue *val)
+{
+  g_free (val->repl);
+  g_free (val);
+}
+
 static gboolean
 suggest_update_accumulator (G_GNUC_UNUSED GSignalInvocationHint *ihint,
                            GValue *return_accu,
@@ -853,8 +868,8 @@ gda_meta_store_init (GdaMetaStore *store)
        priv->parser = gda_sql_parser_new ();
        priv->provider_specifics = g_hash_table_new_full (ProviderSpecific_hash,
                                                     ProviderSpecific_equal,
-                                                    (GDestroyNotify) g_free,
-                                                    (GDestroyNotify) g_free);
+                                                    (GDestroyNotify) provider_specific_key_free,
+                                                    (GDestroyNotify) provider_specific_value_free);
 
        /* priv->provider_specifics = g_hash_table_new (ProviderSpecific_hash, ProviderSpecific_equal); */
        priv->db_objects_hash = g_hash_table_new (g_str_hash, g_str_equal);


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