[libgda] Memory leaks corrections
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Memory leaks corrections
- Date: Wed, 23 Jan 2013 20:58:23 +0000 (UTC)
commit e2519d17ea7920467005fef81d9af22d02d5e5d9
Author: Vivien Malerba <malerba gnome-db org>
Date: Wed Jan 23 21:54:27 2013 +0100
Memory leaks corrections
libgda/gda-connection.c | 1 +
providers/reuseable/mysql/gda-mysql-meta.c | 50 +++++++++++----------
providers/reuseable/postgres/gda-postgres-meta.c | 50 +++++++++++----------
3 files changed, 53 insertions(+), 48 deletions(-)
---
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index 3b8904f..b4960ad 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -630,6 +630,7 @@ gda_connection_finalize (GObject *object)
#if GLIB_CHECK_VERSION(2,31,7)
g_cond_clear (& cnc->priv->unique_possible_cond);
g_mutex_clear (& cnc->priv->object_mutex);
+ g_rec_mutex_clear (&cnc->priv->rmutex);
#else
if (cnc->priv->unique_possible_cond)
g_cond_free (cnc->priv->unique_possible_cond);
diff --git a/providers/reuseable/mysql/gda-mysql-meta.c b/providers/reuseable/mysql/gda-mysql-meta.c
index 0ef1f62..8f77c2b 100644
--- a/providers/reuseable/mysql/gda-mysql-meta.c
+++ b/providers/reuseable/mysql/gda-mysql-meta.c
@@ -239,8 +239,9 @@ static gchar *internal_sql[] = {
* global static values, and
* predefined statements' GdaStatement, all initialized in _gda_postgres_provider_meta_init()
*/
-static GdaStatement **internal_stmt;
-static GdaSet *i_set;
+static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
+static GdaStatement **internal_stmt = NULL;
+static GdaSet *i_set = NULL;
/*
* Meta initialization
@@ -248,30 +249,31 @@ static GdaSet *i_set;
void
_gda_mysql_provider_meta_init (GdaServerProvider *provider)
{
- static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
- InternalStatementItem i;
- GdaSqlParser *parser;
-
g_static_mutex_lock (&init_mutex);
- if (provider)
- parser = gda_server_provider_internal_get_parser (provider);
- else
- parser = GDA_SQL_PARSER (g_object_new (GDA_TYPE_MYSQL_PARSER, NULL));
- internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
- for (i = I_STMT_CATALOG; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
- internal_stmt[i] = gda_sql_parser_parse_string (parser, internal_sql[i], NULL, NULL);
- if (!internal_stmt[i])
- g_error ("Could not parse internal statement: %s\n", internal_sql[i]);
- }
-
- if (!provider)
- g_object_unref (parser);
-
- /* initialize static values here */
- i_set = gda_set_new_inline (3, "name", G_TYPE_STRING, "",
- "schema", G_TYPE_STRING, "",
- "name2", G_TYPE_STRING, "");
+ if (!internal_stmt) {
+ InternalStatementItem i;
+ GdaSqlParser *parser;
+
+ if (provider)
+ parser = gda_server_provider_internal_get_parser (provider);
+ else
+ parser = GDA_SQL_PARSER (g_object_new (GDA_TYPE_MYSQL_PARSER, NULL));
+ internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
+ for (i = I_STMT_CATALOG; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
+ internal_stmt[i] = gda_sql_parser_parse_string (parser, internal_sql[i], NULL, NULL);
+ if (!internal_stmt[i])
+ g_error ("Could not parse internal statement: %s\n", internal_sql[i]);
+ }
+
+ if (!provider)
+ g_object_unref (parser);
+
+ /* initialize static values here */
+ i_set = gda_set_new_inline (3, "name", G_TYPE_STRING, "",
+ "schema", G_TYPE_STRING, "",
+ "name2", G_TYPE_STRING, "");
+ }
g_static_mutex_unlock (&init_mutex);
diff --git a/providers/reuseable/postgres/gda-postgres-meta.c b/providers/reuseable/postgres/gda-postgres-meta.c
index fea38c7..435f5b2 100644
--- a/providers/reuseable/postgres/gda-postgres-meta.c
+++ b/providers/reuseable/postgres/gda-postgres-meta.c
@@ -271,8 +271,9 @@ static gchar *internal_sql[] = {
* global static values, and
* predefined statements' GdaStatement, all initialized in _gda_postgres_provider_meta_init()
*/
-static GdaStatement **internal_stmt;
-static GdaSet *i_set;
+static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
+static GdaStatement **internal_stmt = NULL;
+static GdaSet *i_set = NULL;
/*
* Meta initialization
@@ -280,30 +281,31 @@ static GdaSet *i_set;
void
_gda_postgres_provider_meta_init (GdaServerProvider *provider)
{
- static GStaticMutex init_mutex = G_STATIC_MUTEX_INIT;
- InternalStatementItem i;
- GdaSqlParser *parser;
-
g_static_mutex_lock (&init_mutex);
- if (provider)
- parser = gda_server_provider_internal_get_parser (provider);
- else
- parser = GDA_SQL_PARSER (g_object_new (GDA_TYPE_POSTGRES_PARSER, NULL));
- internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
- for (i = I_STMT_CATALOG; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
- internal_stmt[i] = gda_sql_parser_parse_string (parser, internal_sql[i], NULL, NULL);
- if (!internal_stmt[i])
- g_error ("Could not parse internal statement: %s\n", internal_sql[i]);
- }
- if (!provider)
- g_object_unref (parser);
-
- i_set = gda_set_new_inline (5, "cat", G_TYPE_STRING, "",
- "name", G_TYPE_STRING, "",
- "schema", G_TYPE_STRING, "",
- "name2", G_TYPE_STRING, "",
- "oid", G_TYPE_UINT, 0);
+ if (!internal_stmt) {
+ InternalStatementItem i;
+ GdaSqlParser *parser;
+
+ if (provider)
+ parser = gda_server_provider_internal_get_parser (provider);
+ else
+ parser = GDA_SQL_PARSER (g_object_new (GDA_TYPE_POSTGRES_PARSER, NULL));
+ internal_stmt = g_new0 (GdaStatement *, sizeof (internal_sql) / sizeof (gchar*));
+ for (i = I_STMT_CATALOG; i < sizeof (internal_sql) / sizeof (gchar*); i++) {
+ internal_stmt[i] = gda_sql_parser_parse_string (parser, internal_sql[i], NULL, NULL);
+ if (!internal_stmt[i])
+ g_error ("Could not parse internal statement: %s\n", internal_sql[i]);
+ }
+ if (!provider)
+ g_object_unref (parser);
+
+ i_set = gda_set_new_inline (5, "cat", G_TYPE_STRING, "",
+ "name", G_TYPE_STRING, "",
+ "schema", G_TYPE_STRING, "",
+ "name2", G_TYPE_STRING, "",
+ "oid", G_TYPE_UINT, 0);
+ }
g_static_mutex_unlock (&init_mutex);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]