[libgda] Removing warnings about GFunc and some others
- From: Daniel Espinosa Ortiz <despinosa src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Removing warnings about GFunc and some others
- Date: Thu, 4 Apr 2019 19:48:39 +0000 (UTC)
commit 2b9ee3aa5b09e7675d0bb0d0e7fb9ba20fa31aae
Author: Daniel Espinosa <esodan gmail com>
Date: Wed Apr 3 14:00:47 2019 -0600
Removing warnings about GFunc and some others
libgda-ui/data-entries/plugins/common-pict.c | 3 +-
libgda-ui/demos/tree.c | 7 +++-
libgda-ui/gdaui-cloud.c | 19 ++++++----
libgda-ui/gdaui-raw-grid.c | 15 +++-----
libgda-ui/gdaui-server-operation.c | 6 +--
libgda/gda-batch.c | 3 +-
libgda/gda-config.c | 6 +--
libgda/gda-connection.c | 20 ++++------
libgda/gda-data-access-wrapper.c | 3 +-
libgda/gda-data-model-array.c | 16 ++++----
libgda/gda-data-model-dir.c | 9 ++---
libgda/gda-data-model-import.c | 27 +++++---------
libgda/gda-data-proxy.c | 6 +--
libgda/gda-meta-struct.c | 6 +--
libgda/gda-repetitive-statement.c | 3 +-
libgda/gda-server-operation.c | 9 ++---
libgda/gda-set.c | 12 ++----
libgda/gda-sql-builder.c | 3 +-
libgda/gda-transaction-status.c | 3 +-
libgda/gda-tree-mgr-columns.c | 3 +-
libgda/gda-tree-mgr-label.c | 7 +++-
libgda/gda-tree-mgr-schemas.c | 3 +-
libgda/gda-tree-mgr-select.c | 3 +-
libgda/gda-tree-mgr-tables.c | 3 +-
libgda/gda-tree-node.c | 6 +--
libgda/gda-tree.c | 12 ++----
libgda/providers-support/gda-pstmt.c | 9 ++---
libgda/sql-parser/delimiter.y | 2 +-
libgda/sql-parser/gda-sql-parser.c | 6 +--
libgda/sql-parser/gda-statement-struct-compound.c | 3 +-
libgda/sql-parser/gda-statement-struct-insert.c | 3 +-
libgda/sql-parser/gda-statement-struct-parts.c | 18 +++------
libgda/sql-parser/gda-statement-struct-select.c | 9 ++---
libgda/sql-parser/gda-statement-struct-unknown.c | 3 +-
libgda/sql-parser/parser.y | 27 +++++++-------
libgda/sqlite/virtual/gda-vconnection-data-model.c | 22 ++++++++---
libgda/thread-wrapper/itsignaler.c | 4 +-
libgda/thread-wrapper/itsignaler.h | 1 +
libgda/thread-wrapper/test-itsignaler.c | 2 +-
providers/oracle/parser.y | 27 +++++++-------
providers/skel-implementation/capi/gda-capi-ddl.c | 3 +-
.../skel-implementation/capi/gda-capi-provider.c | 3 +-
providers/skel-implementation/capi/parser.y | 27 +++++++-------
.../models/gda-models-provider.c | 43 +++-------------------
.../models/gda-models-provider.h | 14 +------
tests/meta-store/common.c | 3 +-
tests/multi-threading/common.c | 3 +-
tests/value-holders/check_set.c | 3 +-
48 files changed, 178 insertions(+), 270 deletions(-)
---
diff --git a/libgda-ui/data-entries/plugins/common-pict.c b/libgda-ui/data-entries/plugins/common-pict.c
index f1535ae3d..9c25ee78e 100644
--- a/libgda-ui/data-entries/plugins/common-pict.c
+++ b/libgda-ui/data-entries/plugins/common-pict.c
@@ -496,8 +496,7 @@ file_save_cb (GtkMenuItem *mitem, PictMenuData *menudata)
if (dlg)
gtk_widget_destroy (dlg);
- g_slist_foreach (pictformat.formats, (GFunc) g_free, NULL);
- g_slist_free (pictformat.formats);
+ g_slist_free_full (pictformat.formats, (GDestroyNotify) g_free);
}
static void
diff --git a/libgda-ui/demos/tree.c b/libgda-ui/demos/tree.c
index e5dbeb5ac..dce9ac3fb 100644
--- a/libgda-ui/demos/tree.c
+++ b/libgda-ui/demos/tree.c
@@ -71,13 +71,18 @@ timout_cb (GdaTreeNode *node)
return TRUE;
}
+void ref_objects (GObject *object, G_GNUC_UNUSED gpointer user_data)
+{
+ g_object_ref (object);
+}
+
static GSList *
node_func (GdaTreeManager *manager, GdaTreeNode *node, const GSList *children_nodes,
G_GNUC_UNUSED gboolean *out_error, G_GNUC_UNUSED GError **error)
{
if (children_nodes) {
/* we don't create or modify already created GdaTreeNode object => simply ref them */
- g_slist_foreach ((GSList*) children_nodes, (GFunc) g_object_ref, NULL);
+ g_slist_foreach ((GSList*) children_nodes, (GFunc) ref_objects, NULL);
return g_slist_copy ((GSList*) children_nodes);
}
else {
diff --git a/libgda-ui/gdaui-cloud.c b/libgda-ui/gdaui-cloud.c
index 0e832ee13..312972b21 100644
--- a/libgda-ui/gdaui-cloud.c
+++ b/libgda-ui/gdaui-cloud.c
@@ -192,8 +192,7 @@ update_display (GdauiCloud *cloud)
gtk_text_buffer_get_end_iter (tbuffer, &end);
gtk_text_buffer_delete (tbuffer, &start, &end);
if (priv->selected_tags) {
- g_slist_foreach (priv->selected_tags, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->selected_tags);
+ g_slist_free_full (priv->selected_tags, (GDestroyNotify) g_object_unref);
priv->selected_tags = NULL;
sync_iter_with_selection (cloud);
g_signal_emit_by_name (cloud, "selection-changed");
@@ -390,15 +389,21 @@ gdaui_cloud_dispose (GObject *object)
GdauiCloudPrivate *priv = gdaui_cloud_get_instance_private (cloud);
if (priv->selected_tags) {
- g_slist_foreach (priv->selected_tags, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->selected_tags);
+ g_slist_free_full (priv->selected_tags, (GDestroyNotify) g_object_unref);
+ priv->selected_tags = NULL;
}
- if (priv->iter)
+ if (priv->iter) {
g_object_unref (priv->iter);
- if (priv->model)
+ priv->iter = NULL;
+ }
+ if (priv->model) {
g_object_unref (priv->model);
- if (priv->tbuffer)
+ priv->model = NULL;
+ }
+ if (priv->tbuffer) {
g_object_unref (priv->tbuffer);
+ priv->tbuffer = NULL;
+ }
/* for the parent class */
G_OBJECT_CLASS (gdaui_cloud_parent_class)->dispose (object);
diff --git a/libgda-ui/gdaui-raw-grid.c b/libgda-ui/gdaui-raw-grid.c
index d36ccf39e..95305ded8 100644
--- a/libgda-ui/gdaui-raw-grid.c
+++ b/libgda-ui/gdaui-raw-grid.c
@@ -1434,8 +1434,7 @@ tree_view_event_cb (GtkWidget *treeview, GdkEvent *event, GdauiRawGrid *grid)
gdaui_data_store_delete (priv->store, &iter);
cur_row = g_list_next (cur_row);
}
- g_list_foreach (sel_rows, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (sel_rows);
+ g_list_free_full (sel_rows, (GDestroyNotify) gtk_tree_path_free);
done = TRUE;
}
@@ -2138,8 +2137,7 @@ tree_view_selection_changed_cb (GtkTreeSelection *selection, GdauiRawGrid *grid)
sel_rows = gtk_tree_selection_get_selected_rows (selection, &model);
has_selection = gtk_tree_model_get_iter (model, &iter, (GtkTreePath *)
(sel_rows->data)) ? 1 : 0;
- g_list_foreach (sel_rows, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (sel_rows);
+ g_list_free_full (sel_rows, (GDestroyNotify) gtk_tree_path_free);
}
}
else
@@ -2495,8 +2493,7 @@ gdaui_raw_grid_perform_action (GdauiDataProxy *iface, GdauiAction action)
gdaui_data_store_get_row_from_iter
(GDAUI_DATA_STORE (model),
&iter))) {
gdaui_data_store_delete (priv->store, &iter);
- g_list_foreach (sel_rows, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (sel_rows);
+ g_list_free_full (sel_rows, (GDestroyNotify) gtk_tree_path_free);
sel_rows = gtk_tree_selection_get_selected_rows (select, &model);
}
else
@@ -2520,8 +2517,7 @@ gdaui_raw_grid_perform_action (GdauiDataProxy *iface, GdauiAction action)
gdaui_data_store_undelete (priv->store, &iter);
cur_row = g_list_next (cur_row);
}
- g_list_foreach (sel_rows, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (sel_rows);
+ g_list_free_full (sel_rows, (GDestroyNotify) gtk_tree_path_free);
break;
}
@@ -2937,8 +2933,7 @@ gdaui_raw_grid_selector_get_selected_rows (GdauiDataSelector *iface)
g_array_append_val (selarray, row);
}
}
- g_list_foreach (selected_rows, (GFunc) gtk_tree_path_free, NULL);
- g_list_free (selected_rows);
+ g_list_free_full (selected_rows, (GDestroyNotify) gtk_tree_path_free);
return selarray;
}
else
diff --git a/libgda-ui/gdaui-server-operation.c b/libgda-ui/gdaui-server-operation.c
index 0574dddbc..32a63c66a 100644
--- a/libgda-ui/gdaui-server-operation.c
+++ b/libgda-ui/gdaui-server-operation.c
@@ -95,8 +95,7 @@ void
widget_data_free (WidgetData *wd)
{
g_free (wd->path_name);
- g_slist_foreach (wd->children, (GFunc) widget_data_free, NULL);
- g_slist_free (wd->children);
+ g_slist_free_full (wd->children, (GDestroyNotify) widget_data_free);
g_free (wd);
}
@@ -239,8 +238,7 @@ gdaui_server_operation_dispose (GObject *object)
}
if (priv->widget_data) {
- g_slist_foreach (priv->widget_data, (GFunc) widget_data_free, NULL);
- g_slist_free (priv->widget_data);
+ g_slist_free_full (priv->widget_data, (GDestroyNotify) widget_data_free);
priv->widget_data = NULL;
}
diff --git a/libgda/gda-batch.c b/libgda/gda-batch.c
index fa2a58f3b..cae3db17a 100644
--- a/libgda/gda-batch.c
+++ b/libgda/gda-batch.c
@@ -175,8 +175,7 @@ gda_batch_dispose (GObject *object)
batch = GDA_BATCH (object);
GdaBatchPrivate *priv = gda_batch_get_instance_private (batch);
if (priv->statements) {
- g_slist_foreach (priv->statements, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->statements);
+ g_slist_free_full (priv->statements, (GDestroyNotify) g_object_unref);
priv->statements = NULL;
}
diff --git a/libgda/gda-config.c b/libgda/gda-config.c
index 701389107..36cf3d27c 100644
--- a/libgda/gda-config.c
+++ b/libgda/gda-config.c
@@ -1016,13 +1016,11 @@ gda_config_dispose (GObject *object)
}
if (priv->dsn_list) {
- g_slist_foreach (priv->dsn_list, (GFunc) gda_dsn_info_free, NULL);
- g_slist_free (priv->dsn_list);
+ g_slist_free_full (priv->dsn_list, (GDestroyNotify) gda_dsn_info_free);
priv->dsn_list = NULL;
}
if (priv->prov_list) {
- g_slist_foreach (priv->prov_list, (GFunc) internal_provider_free, NULL);
- g_slist_free (priv->prov_list);
+ g_slist_free_full (priv->prov_list, (GDestroyNotify) internal_provider_free);
priv->prov_list = NULL;
}
}
diff --git a/libgda/gda-connection.c b/libgda/gda-connection.c
index ef2e22fa1..ef6decd87 100644
--- a/libgda/gda-connection.c
+++ b/libgda/gda-connection.c
@@ -495,8 +495,7 @@ gda_connection_dispose (GObject *object)
}
if (priv->events_list) {
- g_list_foreach (priv->events_list, (GFunc) g_object_unref, NULL);
- g_list_free (priv->events_list);
+ g_list_free_full (priv->events_list, (GDestroyNotify) g_object_unref);
priv->events_list = NULL;
}
@@ -2209,8 +2208,7 @@ gda_connection_insert_row_into_table_v (GdaConnection *cnc, const gchar *table,
GdaSet *set = NULL;
if (holders) {
set = gda_set_new (holders);
- g_slist_foreach (holders, (GFunc) g_object_unref, NULL);
- g_slist_free (holders);
+ g_slist_free_full (holders, (GDestroyNotify) g_object_unref);
}
retval = (gda_connection_statement_execute_non_select (cnc, insert, set, NULL, error) == -1) ? FALSE
: TRUE;
@@ -2430,8 +2428,7 @@ gda_connection_update_row_in_table_v (GdaConnection *cnc, const gchar *table,
GdaSet *set = NULL;
if (holders) {
set = gda_set_new (holders);
- g_slist_foreach (holders, (GFunc) g_object_unref, NULL);
- g_slist_free (holders);
+ g_slist_free_full (holders, (GDestroyNotify) g_object_unref);
}
retval = (gda_connection_statement_execute_non_select (cnc, update, set, NULL, error) == -1) ? FALSE
: TRUE;
@@ -2532,8 +2529,7 @@ gda_connection_delete_row_from_table (GdaConnection *cnc, const gchar *table,
GdaSet *set = NULL;
if (holders) {
set = gda_set_new (holders);
- g_slist_foreach (holders, (GFunc) g_object_unref, NULL);
- g_slist_free (holders);
+ g_slist_free_full (holders, (GDestroyNotify) g_object_unref);
}
retval = (gda_connection_statement_execute_non_select (cnc, delete, set, NULL, error) == -1) ? FALSE
: TRUE;
@@ -2669,8 +2665,7 @@ gda_connection_add_event (GdaConnection *cnc, GdaConnectionEvent *event)
/* clear external list of events */
if (priv->events_list) {
- g_list_foreach (priv->events_list, (GFunc) g_object_unref, NULL);
- g_list_free (priv->events_list);
+ g_list_free_full (priv->events_list, (GDestroyNotify) g_object_unref);
priv->events_list = NULL;
}
@@ -5247,8 +5242,7 @@ gda_connection_get_meta_store_data (GdaConnection *cnc,
model = gda_connection_get_meta_store_data_v (cnc, meta_type, filters, error);
onerror:
- g_list_foreach (filters, (GFunc) g_object_unref, NULL);
- g_list_free (filters);
+ g_list_free_full (filters, (GDestroyNotify) g_object_unref);
return model;
}
@@ -6283,7 +6277,7 @@ gda_connection_lock (GdaLockable *lockable)
GSource *itsource;
itsource = itsignaler_create_source (its);
g_source_attach (itsource, context);
- g_source_set_callback (itsource, (GSourceFunc) itsignaler_trylock, &lockdata, NULL);
+ g_source_set_callback (itsource, G_SOURCE_FUNC (itsignaler_trylock), &lockdata, NULL);
g_source_unref (itsource);
g_main_loop_run (loop);
diff --git a/libgda/gda-data-access-wrapper.c b/libgda/gda-data-access-wrapper.c
index 59fa6e632..5983b7bf6 100644
--- a/libgda/gda-data-access-wrapper.c
+++ b/libgda/gda-data-access-wrapper.c
@@ -183,8 +183,7 @@ clear_internal_state (GdaDataAccessWrapper *model)
GdaDataAccessWrapperPrivate *priv = gda_data_access_wrapper_get_instance_private (model);
if (priv) {
if (priv->columns) {
- g_slist_foreach (priv->columns, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->columns);
+ g_slist_free_full (priv->columns, (GDestroyNotify) g_object_unref);
priv->columns = NULL;
}
diff --git a/libgda/gda-data-model-array.c b/libgda/gda-data-model-array.c
index 05e38535c..78b559582 100644
--- a/libgda/gda-data-model-array.c
+++ b/libgda/gda-data-model-array.c
@@ -521,7 +521,7 @@ static gint
gda_data_model_array_get_n_rows (GdaDataModel *model)
{
g_return_val_if_fail (GDA_IS_DATA_MODEL_ARRAY (model), -1);
- GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (model);
+ GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (GDA_DATA_MODEL_ARRAY
(model));
return priv->rows->len;
}
@@ -529,7 +529,7 @@ static gint
gda_data_model_array_get_n_columns (GdaDataModel *model)
{
g_return_val_if_fail (GDA_IS_DATA_MODEL_ARRAY (model), -1);
- GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (model);
+ GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (GDA_DATA_MODEL_ARRAY
(model));
return priv->number_of_columns;
}
@@ -537,7 +537,7 @@ static GdaColumn *
gda_data_model_array_describe_column (GdaDataModel *model, gint col)
{
GdaColumn *column;
- GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (model);
+ GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (GDA_DATA_MODEL_ARRAY
(model));
if (col >= gda_data_model_get_n_columns (model)) {
g_warning ("Column %d out of range (0-%d)", col, gda_data_model_get_n_columns (model) - 1);
@@ -659,7 +659,7 @@ gda_data_model_array_get_attributes_at (GdaDataModel *model, gint col, gint row)
const GValue *gdavalue;
GdaValueAttribute flags = 0;
GdaColumn *column;
- GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (model);
+ GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (GDA_DATA_MODEL_ARRAY
(model));
column = gda_data_model_array_describe_column (model, col);
if (gda_column_get_allow_null (column))
@@ -683,7 +683,7 @@ gda_data_model_array_get_attributes_at (GdaDataModel *model, gint col, gint row)
static GdaDataModelAccessFlags
gda_data_model_array_get_access_flags (GdaDataModel *model)
{
- GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (model);
+ GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (GDA_DATA_MODEL_ARRAY
(model));
GdaDataModelAccessFlags flags = GDA_DATA_MODEL_ACCESS_RANDOM |
GDA_DATA_MODEL_ACCESS_CURSOR_FORWARD |
GDA_DATA_MODEL_ACCESS_CURSOR_BACKWARD;
@@ -859,20 +859,20 @@ gda_data_model_array_remove_row (GdaDataModel *model, gint row, GError **error)
static void
gda_data_model_array_freeze (GdaDataModel *model)
{
- GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (model);
+ GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (GDA_DATA_MODEL_ARRAY
(model));
priv->notify_changes = FALSE;
}
static void
gda_data_model_array_thaw (GdaDataModel *model)
{
- GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (model);
+ GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (GDA_DATA_MODEL_ARRAY
(model));
priv->notify_changes = TRUE;
}
static gboolean
gda_data_model_array_get_notify (GdaDataModel *model)
{
- GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (model);
+ GdaDataModelArrayPrivate *priv = gda_data_model_array_get_instance_private (GDA_DATA_MODEL_ARRAY
(model));
return priv->notify_changes;
}
diff --git a/libgda/gda-data-model-dir.c b/libgda/gda-data-model-dir.c
index b653f0ff0..35499fe5d 100644
--- a/libgda/gda-data-model-dir.c
+++ b/libgda/gda-data-model-dir.c
@@ -220,13 +220,11 @@ gda_data_model_dir_dispose (GObject * object)
}
if (priv->errors) {
- g_slist_foreach (priv->errors, (GFunc) g_error_free, NULL);
- g_slist_free (priv->errors);
+ g_slist_free_full (priv->errors, (GDestroyNotify) g_error_free);
}
if (priv->columns) {
- g_slist_foreach (priv->columns, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->columns);
+ g_slist_free_full (priv->columns, (GDestroyNotify) g_object_unref);
priv->columns = NULL;
}
@@ -654,8 +652,7 @@ gda_data_model_dir_clean_errors (GdaDataModelDir *model)
GdaDataModelDirPrivate *priv = gda_data_model_dir_get_instance_private (model);
if (priv->errors) {
- g_slist_foreach (priv->errors, (GFunc) g_error_free, NULL);
- g_slist_free (priv->errors);
+ g_slist_free_full (priv->errors, (GDestroyNotify) g_error_free);
priv->errors = NULL;
}
}
diff --git a/libgda/gda-data-model-import.c b/libgda/gda-data-model-import.c
index 8003602d3..a36eb446d 100644
--- a/libgda/gda-data-model-import.c
+++ b/libgda/gda-data-model-import.c
@@ -570,14 +570,12 @@ csv_free_stored_rows (GdaDataModelImport *model)
for (i = 0; i < priv->extract.csv.rows_read->len; i++) {
GSList *list = g_array_index (priv->extract.csv.rows_read,
GSList *, i);
- g_slist_foreach (list, (GFunc) gda_value_free, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, (GDestroyNotify) gda_value_free);
}
if (priv->extract.csv.pdata) {
if (priv->extract.csv.pdata->fields) {
- g_slist_foreach (priv->extract.csv.pdata->fields, (GFunc) gda_value_free, NULL);
- g_slist_free (priv->extract.csv.pdata->fields);
+ g_slist_free_full (priv->extract.csv.pdata->fields, (GDestroyNotify) gda_value_free);
}
g_free (priv->extract.csv.pdata);
}
@@ -601,8 +599,7 @@ gda_data_model_import_dispose (GObject *object)
}
if (priv->columns) {
- g_slist_foreach (priv->columns, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->columns);
+ g_slist_free_full (priv->columns, (GDestroyNotify) g_object_unref);
priv->columns = NULL;
}
@@ -675,14 +672,12 @@ gda_data_model_import_finalize (GObject *object)
/* free memory */
if (priv->errors) {
- g_slist_foreach (priv->errors, (GFunc) g_error_free, NULL);
- g_slist_free (priv->errors);
+ g_slist_free_full (priv->errors, (GDestroyNotify) g_error_free);
priv->errors = NULL;
}
if (priv->cursor_values) {
- g_slist_foreach (priv->cursor_values, (GFunc) gda_value_free, NULL);
- g_slist_free (priv->cursor_values);
+ g_slist_free_full (priv->cursor_values, (GDestroyNotify) gda_value_free);
priv->cursor_values = NULL;
}
@@ -701,8 +696,7 @@ find_option_as_string (GdaDataModelImport *model, const gchar *pname)
value = gda_set_get_holder_value (priv->options, pname);
if (value && !gda_value_is_null ((GValue *) value)) {
if (!gda_value_isa ((GValue *) value, G_TYPE_STRING))
- g_warning (_("The '%s' option must hold a "
- "string value, ignored."), pname);
+ g_warning (_("The %s option must hold a string value, ignored."), pname);
else
return g_value_get_string ((GValue *) value);
}
@@ -1426,8 +1420,7 @@ xml_fetch_next_row (GdaDataModelImport *model)
GSList *values = NULL;
if (priv->cursor_values) {
- g_slist_foreach (priv->cursor_values, (GFunc) gda_value_free, NULL);
- g_slist_free (priv->cursor_values);
+ g_slist_free_full (priv->cursor_values, (GDestroyNotify) gda_value_free);
priv->cursor_values = NULL;
}
@@ -1757,8 +1750,7 @@ gda_data_model_import_clean_errors (GdaDataModelImport *model)
g_return_if_fail (GDA_IS_DATA_MODEL_IMPORT (model));
GdaDataModelImportPrivate *priv = gda_data_model_import_get_instance_private (model);
- g_slist_foreach (priv->errors, (GFunc) g_error_free, NULL);
- g_slist_free (priv->errors);
+ g_slist_free_full (priv->errors, (GDestroyNotify) g_error_free);
priv->errors = NULL;
}
@@ -1984,8 +1976,7 @@ gda_data_model_import_iter_next (GdaDataModel *model, GdaDataModelIter *iter)
GSList *list = g_array_index (priv->extract.csv.rows_read,
GSList *, 0);
g_assert (list);
- g_slist_foreach (list, (GFunc) gda_value_free, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, (GDestroyNotify) gda_value_free);
g_array_remove_index (priv->extract.csv.rows_read, 0);
}
diff --git a/libgda/gda-data-proxy.c b/libgda/gda-data-proxy.c
index 1457ba078..f0310e561 100644
--- a/libgda/gda-data-proxy.c
+++ b/libgda/gda-data-proxy.c
@@ -2097,8 +2097,7 @@ commit_row_modif (GdaDataProxy *proxy, RowModif *rm, gboolean adjust_display, GE
err = ! gda_data_model_set_values (priv->model, rm->model_row,
values, error);
- g_list_foreach (values, (GFunc) gda_value_free, NULL);
- g_list_free (values);
+ g_list_free_full (values, (GDestroyNotify) gda_value_free);
}
else {
/* insert a new row */
@@ -3300,8 +3299,7 @@ gda_data_proxy_set_ordering_column (GdaDataProxy *proxy, gint col, GError **erro
if (!replaced) {
/* replace the whole ordering part */
if (selst->order_by) {
- g_slist_foreach (selst->order_by, (GFunc) gda_sql_select_order_free, NULL);
- g_slist_free (selst->order_by);
+ g_slist_free_full (selst->order_by, (GDestroyNotify)
gda_sql_select_order_free);
selst->order_by = NULL;
}
diff --git a/libgda/gda-meta-struct.c b/libgda/gda-meta-struct.c
index d61ee6c25..134b18894 100644
--- a/libgda/gda-meta-struct.c
+++ b/libgda/gda-meta-struct.c
@@ -2065,11 +2065,9 @@ gda_meta_db_object_free (GdaMetaDbObject *dbo)
static void
gda_meta_table_free_contents (GdaMetaTable *table)
{
- g_slist_foreach (table->columns, (GFunc) gda_meta_table_column_free, NULL);
- g_slist_free (table->columns);
+ g_slist_free_full (table->columns, (GDestroyNotify) gda_meta_table_column_free);
g_free (table->pk_cols_array);
- g_slist_foreach (table->fk_list, (GFunc) gda_meta_table_foreign_key_free, NULL);
- g_slist_free (table->fk_list);
+ g_slist_free_full (table->fk_list, (GDestroyNotify) gda_meta_table_foreign_key_free);
g_slist_free (table->reverse_fk_list);
}
diff --git a/libgda/gda-repetitive-statement.c b/libgda/gda-repetitive-statement.c
index 2ace42d6c..8103695d7 100644
--- a/libgda/gda-repetitive-statement.c
+++ b/libgda/gda-repetitive-statement.c
@@ -57,8 +57,7 @@ gda_repetitive_statement_finalize (GObject *object)
priv = GDA_REPETITIVE_STATEMENT_PRIVATE (object);
g_object_unref (priv->statement);
- g_slist_foreach (priv->values_sets, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->values_sets);
+ g_slist_free_full (priv->values_sets, (GDestroyNotify) g_object_unref);
G_OBJECT_CLASS (gda_repetitive_statement_parent_class)->finalize (object);
}
diff --git a/libgda/gda-server-operation.c b/libgda/gda-server-operation.c
index 6e4a3372a..e53ba437f 100644
--- a/libgda/gda-server-operation.c
+++ b/libgda/gda-server-operation.c
@@ -8,7 +8,7 @@
* Copyright (C) 2009 Bas Driessen <bas driessen xobas com>
* Copyright (C) 2010 David King <davidk openismus com>
* Copyright (C) 2010 Jonh Wendell <jwendell gnome org>
- * Copyright (C) 2011 - 2012 Daniel Espinosa <despinosa src gnome org>
+ * Copyright (C) 2011 - 2012, 2019 Daniel Espinosa <esodan gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -258,8 +258,8 @@ gda_server_operation_dispose (GObject *object)
/* don't free priv->xml_spec_doc */
if (priv->sources) {
- g_slist_foreach (priv->sources, (GFunc) g_object_unref, NULL);
- g_clear_pointer(&priv->sources, g_slist_free);
+ g_slist_free_full (priv->sources, (GDestroyNotify) g_object_unref);
+ priv->sources = NULL;
}
/* chain to parent class */
@@ -833,8 +833,7 @@ load_xml_spec (GdaServerOperation *op, xmlNodePtr specnode, const gchar *root, G
if (errors) {
g_object_unref (model);
if (sources) {
- g_slist_foreach (sources, (GFunc) g_object_unref,
NULL);
- g_slist_free (sources);
+ g_slist_free_full (sources, (GDestroyNotify)
g_object_unref);
return NULL;
}
}
diff --git a/libgda/gda-set.c b/libgda/gda-set.c
index 216e23b77..3595a8414 100644
--- a/libgda/gda-set.c
+++ b/libgda/gda-set.c
@@ -1061,8 +1061,7 @@ gda_set_copy (GdaSet *set)
holders = g_slist_reverse (holders);
copy = g_object_new (GDA_TYPE_SET, "holders", holders, NULL);
- g_slist_foreach (holders, (GFunc) g_object_unref, NULL);
- g_slist_free (holders);
+ g_slist_free_full (holders, (GDestroyNotify) g_object_unref);
return copy;
}
@@ -1172,8 +1171,7 @@ gda_set_new_inline (gint nb, ...)
if (allok)
set = gda_set_new (holders);
if (holders) {
- g_slist_foreach (holders, (GFunc) g_object_unref, NULL);
- g_slist_free (holders);
+ g_slist_free_full (holders, (GDestroyNotify) g_object_unref);
}
return set;
}
@@ -1564,10 +1562,8 @@ gda_set_new_from_spec_node (xmlNodePtr xml_spec, GError **error)
}
}
- g_slist_foreach (holders, (GFunc) g_object_unref, NULL);
- g_slist_free (holders);
- g_slist_foreach (sources, (GFunc) g_object_unref, NULL);
- g_slist_free (sources);
+ g_slist_free_full (holders, (GDestroyNotify) g_object_unref);
+ g_slist_free_full (sources, (GDestroyNotify) g_object_unref);
return set;
}
diff --git a/libgda/gda-sql-builder.c b/libgda/gda-sql-builder.c
index c0039b35c..490bab9d4 100644
--- a/libgda/gda-sql-builder.c
+++ b/libgda/gda-sql-builder.c
@@ -1634,8 +1634,7 @@ gda_sql_builder_select_group_by (GdaSqlBuilder *builder, GdaSqlBuilderId expr_id
(GdaSqlExpr*) use_part (p, GDA_SQL_ANY_PART (sel)));
else if (sel->group_by)
{
- g_slist_foreach (sel->group_by, (GFunc) gda_sql_expr_free, NULL);
- g_slist_free (sel->group_by);
+ g_slist_free_full (sel->group_by, (GDestroyNotify) gda_sql_expr_free);
sel->group_by = NULL;
}
}
diff --git a/libgda/gda-transaction-status.c b/libgda/gda-transaction-status.c
index 848e589b3..b801f35b6 100644
--- a/libgda/gda-transaction-status.c
+++ b/libgda/gda-transaction-status.c
@@ -99,8 +99,7 @@ gda_transaction_status_finalize (GObject *object)
}
if (priv->events) {
- g_list_foreach (priv->events, (GFunc) event_free, NULL);
- g_list_free (priv->events);
+ g_list_free_full (priv->events, (GDestroyNotify) event_free);
priv->events = NULL;
}
diff --git a/libgda/gda-tree-mgr-columns.c b/libgda/gda-tree-mgr-columns.c
index 5ce0a1172..82ff311f4 100644
--- a/libgda/gda-tree-mgr-columns.c
+++ b/libgda/gda-tree-mgr-columns.c
@@ -381,8 +381,7 @@ gda_tree_mgr_columns_update_children (GdaTreeManager *manager, GdaTreeNode *node
cvalue = gda_data_model_iter_get_value_at (iter, 0);
if (!cvalue) {
if (list) {
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, (GDestroyNotify) g_object_unref);
}
if (out_error)
*out_error = TRUE;
diff --git a/libgda/gda-tree-mgr-label.c b/libgda/gda-tree-mgr-label.c
index 006bce211..4a7c75160 100644
--- a/libgda/gda-tree-mgr-label.c
+++ b/libgda/gda-tree-mgr-label.c
@@ -154,13 +154,18 @@ gda_tree_mgr_label_new (const gchar *label)
return (GdaTreeManager*) mgr;
}
+void ref_elements (GObject *object, G_GNUC_UNUSED gpointer user_data)
+{
+ g_object_ref (object);
+}
+
static GSList *
gda_tree_mgr_label_update_children (GdaTreeManager *manager, GdaTreeNode *node, const GSList *children_nodes,
G_GNUC_UNUSED gboolean *out_error, G_GNUC_UNUSED GError **error)
{
if (children_nodes) {
GSList *list = g_slist_copy ((GSList*) children_nodes);
- g_slist_foreach (list, (GFunc) g_object_ref, NULL);
+ g_slist_foreach (list, (GFunc) ref_elements, NULL);
return list;
}
diff --git a/libgda/gda-tree-mgr-schemas.c b/libgda/gda-tree-mgr-schemas.c
index 0ede2579b..59726117a 100644
--- a/libgda/gda-tree-mgr-schemas.c
+++ b/libgda/gda-tree-mgr-schemas.c
@@ -259,8 +259,7 @@ gda_tree_mgr_schemas_update_children (GdaTreeManager *manager, GdaTreeNode *node
cvalue = gda_data_model_iter_get_value_at (iter, 0);
if (!cvalue) {
if (list) {
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, (GDestroyNotify) g_object_unref);
}
if (out_error)
*out_error = TRUE;
diff --git a/libgda/gda-tree-mgr-select.c b/libgda/gda-tree-mgr-select.c
index 7aab1d311..11c7d78e8 100644
--- a/libgda/gda-tree-mgr-select.c
+++ b/libgda/gda-tree-mgr-select.c
@@ -307,8 +307,7 @@ gda_tree_mgr_select_update_children (GdaTreeManager *manager, GdaTreeNode *node,
if (!gda_holder_is_valid (holder) || !(cvalue = gda_holder_get_value (holder))) {
if (list) {
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, (GDestroyNotify) g_object_unref);
}
if (out_error)
diff --git a/libgda/gda-tree-mgr-tables.c b/libgda/gda-tree-mgr-tables.c
index f9d8526b9..c4775159a 100644
--- a/libgda/gda-tree-mgr-tables.c
+++ b/libgda/gda-tree-mgr-tables.c
@@ -347,8 +347,7 @@ gda_tree_mgr_tables_update_children (GdaTreeManager *manager, GdaTreeNode *node,
cvalue2 = gda_data_model_iter_get_value_at (iter, 1);
if (!cvalue || !cvalue2) {
if (list) {
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, (GDestroyNotify) g_object_unref);
}
if (out_error)
*out_error = TRUE;
diff --git a/libgda/gda-tree-node.c b/libgda/gda-tree-node.c
index 9d332de1a..f22c76399 100644
--- a/libgda/gda-tree-node.c
+++ b/libgda/gda-tree-node.c
@@ -278,8 +278,7 @@ gda_tree_node_dispose (GObject *object)
GdaTreeNodePrivate *priv = gda_tree_node_get_instance_private (tnode);
if (priv->children != NULL) {
- g_slist_foreach (priv->children, (GFunc) _gda_nodes_list_free, NULL);
- g_slist_free (priv->children);
+ g_slist_free_full (priv->children, (GDestroyNotify) _gda_nodes_list_free);
priv->children = NULL;
}
if (priv->name != NULL) {
@@ -869,8 +868,7 @@ void
_gda_nodes_list_free (GdaTreeNodesList *nl)
{
if (nl->nodes) {
- g_slist_foreach (nl->nodes, (GFunc) g_object_unref, NULL);
- g_slist_free (nl->nodes);
+ g_slist_free_full (nl->nodes, (GDestroyNotify) g_object_unref);
}
g_object_unref (nl->mgr);
g_free (nl);
diff --git a/libgda/gda-tree.c b/libgda/gda-tree.c
index 0aa125337..8413d0d7b 100644
--- a/libgda/gda-tree.c
+++ b/libgda/gda-tree.c
@@ -196,8 +196,7 @@ gda_tree_dispose (GObject *object)
if (priv->root)
unset_root_node (tree);
if (priv->managers) {
- g_slist_foreach (priv->managers, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->managers);
+ g_slist_free_full (priv->managers, (GDestroyNotify) g_object_unref);
}
/* chain to parent class */
G_OBJECT_CLASS (gda_tree_parent_class)->dispose (object);
@@ -483,8 +482,7 @@ gda_tree_get_nodes_in_path (GdaTree *tree, const gchar *tree_path, gboolean use_
segments = decompose_path_as_segments (tree_path, use_names);
nodes = real_gda_tree_get_nodes_in_path (tree, segments, use_names, NULL);
if (segments) {
- g_slist_foreach (segments, (GFunc) g_free, NULL);
- g_slist_free (segments);
+ g_slist_free_full (segments, (GDestroyNotify) g_free);
}
}
else {
@@ -639,8 +637,7 @@ gda_tree_get_node (GdaTree *tree, const gchar *tree_path, gboolean use_names)
g_assert (real_gda_tree_get_nodes_in_path (tree, segments, use_names, &node) == NULL);
if (segments) {
- g_slist_foreach (segments, (GFunc) g_free, NULL);
- g_slist_free (segments);
+ g_slist_free_full (segments, (GDestroyNotify) g_free);
}
return node;
@@ -798,8 +795,7 @@ split_indexed_path (const gchar *path, gboolean *out_error)
if ((*end < '0') || (*end > '9')) {
/* error */
*out_error = TRUE;
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, (GDestroyNotify) g_free);
g_free (copy);
return NULL;
}
diff --git a/libgda/providers-support/gda-pstmt.c b/libgda/providers-support/gda-pstmt.c
index c45b616c2..7c32840df 100644
--- a/libgda/providers-support/gda-pstmt.c
+++ b/libgda/providers-support/gda-pstmt.c
@@ -107,8 +107,7 @@ gda_pstmt_dispose (GObject *object)
priv->sql = NULL;
}
if (priv->param_ids != NULL) {
- g_slist_foreach (priv->param_ids, (GFunc) g_free, NULL);
- g_slist_free (priv->param_ids);
+ g_slist_free_full (priv->param_ids, (GDestroyNotify) g_free);
priv->param_ids = NULL;
}
if (priv->types != NULL) {
@@ -116,8 +115,7 @@ gda_pstmt_dispose (GObject *object)
priv->types = NULL;
}
if (priv->tmpl_columns != NULL) {
- g_slist_foreach (priv->tmpl_columns, (GFunc) g_object_unref, NULL);
- g_slist_free (priv->tmpl_columns);
+ g_slist_free_full (priv->tmpl_columns, (GDestroyNotify) g_object_unref);
priv->tmpl_columns = NULL;
}
@@ -184,8 +182,7 @@ gda_pstmt_copy_contents (GdaPStmt *src, GdaPStmt *dest)
if (priv->sql)
dpriv->sql = g_strdup (priv->sql);
if (dpriv->param_ids) {
- g_slist_foreach (dpriv->param_ids, (GFunc) g_free, NULL);
- g_slist_free (dpriv->param_ids);
+ g_slist_free_full (dpriv->param_ids, (GDestroyNotify) g_free);
dpriv->param_ids = NULL;
}
for (list = priv->param_ids; list; list = list->next)
diff --git a/libgda/sql-parser/delimiter.y b/libgda/sql-parser/delimiter.y
index 3cb93c5b6..8ded8435b 100644
--- a/libgda/sql-parser/delimiter.y
+++ b/libgda/sql-parser/delimiter.y
@@ -70,7 +70,7 @@ stmt ::= exprlist(L) END_OF_FILE. {pdata->parsed_statement = gda_sql_statement_n
// List of expressions
%type exprlist {GSList *}
-%destructor exprlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor exprlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
exprlist(L) ::= exprlist(E) expr(X). {L = g_slist_prepend (E, X);}
exprlist(L) ::= expr(E). {L = g_slist_append (NULL, E);}
diff --git a/libgda/sql-parser/gda-sql-parser.c b/libgda/sql-parser/gda-sql-parser.c
index bbbcc728e..675d2e592 100644
--- a/libgda/sql-parser/gda-sql-parser.c
+++ b/libgda/sql-parser/gda-sql-parser.c
@@ -176,14 +176,12 @@ gda_sql_parser_reset (GdaSqlParser *parser)
priv->error_pos = 0;
if (priv->parsed_statements) {
- g_slist_foreach (priv->parsed_statements, (GFunc) gda_sql_statement_free, NULL);
- g_slist_free (priv->parsed_statements);
+ g_slist_free_full (priv->parsed_statements, (GDestroyNotify) gda_sql_statement_free);
priv->parsed_statements = NULL;
}
if (priv->pushed_contexts) {
- g_slist_foreach (priv->pushed_contexts, (GFunc) g_free, NULL);
- g_slist_free (priv->pushed_contexts);
+ g_slist_free_full (priv->pushed_contexts, (GDestroyNotify) g_free);
priv->pushed_contexts = NULL;
}
diff --git a/libgda/sql-parser/gda-statement-struct-compound.c
b/libgda/sql-parser/gda-statement-struct-compound.c
index 88cf3e9a6..015002a22 100644
--- a/libgda/sql-parser/gda-statement-struct-compound.c
+++ b/libgda/sql-parser/gda-statement-struct-compound.c
@@ -68,8 +68,7 @@ _gda_sql_statement_compound_free (gpointer stmt)
GdaSqlStatementCompound *compound = (GdaSqlStatementCompound *) stmt;
if (compound->stmt_list) {
- g_slist_foreach (compound->stmt_list, (GFunc) gda_sql_statement_free, NULL);
- g_slist_free (compound->stmt_list);
+ g_slist_free_full (compound->stmt_list, (GDestroyNotify) gda_sql_statement_free);
}
g_free (compound);
}
diff --git a/libgda/sql-parser/gda-statement-struct-insert.c b/libgda/sql-parser/gda-statement-struct-insert.c
index bbfaa3500..745b2b642 100644
--- a/libgda/sql-parser/gda-statement-struct-insert.c
+++ b/libgda/sql-parser/gda-statement-struct-insert.c
@@ -75,8 +75,7 @@ gda_sql_statement_insert_free (gpointer stmt)
gda_sql_table_free (insert->table);
for (list = insert->values_list; list; list = list->next) {
if (list->data) {
- g_slist_foreach ((GSList *) list->data, (GFunc) gda_sql_expr_free, NULL);
- g_slist_free ((GSList *) list->data);
+ g_slist_free_full ((GSList *) list->data, (GDestroyNotify) gda_sql_expr_free);
}
}
g_slist_free (insert->values_list);
diff --git a/libgda/sql-parser/gda-statement-struct-parts.c b/libgda/sql-parser/gda-statement-struct-parts.c
index 20e8099a1..f05b5863f 100644
--- a/libgda/sql-parser/gda-statement-struct-parts.c
+++ b/libgda/sql-parser/gda-statement-struct-parts.c
@@ -623,8 +623,7 @@ gda_sql_operation_free (GdaSqlOperation *operation)
if (!operation) return;
if (operation->operands) {
- g_slist_foreach (operation->operands, (GFunc) gda_sql_expr_free, NULL);
- g_slist_free (operation->operands);
+ g_slist_free_full (operation->operands, (GDestroyNotify) gda_sql_expr_free);
}
g_free (operation);
}
@@ -905,12 +904,10 @@ gda_sql_case_free (GdaSqlCase *sc)
gda_sql_expr_free (sc->base_expr);
gda_sql_expr_free (sc->else_expr);
if (sc->when_expr_list) {
- g_slist_foreach (sc->when_expr_list, (GFunc) gda_sql_expr_free, NULL);
- g_slist_free (sc->when_expr_list);
+ g_slist_free_full (sc->when_expr_list, (GDestroyNotify) gda_sql_expr_free);
}
if (sc->then_expr_list) {
- g_slist_foreach (sc->then_expr_list, (GFunc) gda_sql_expr_free, NULL);
- g_slist_free (sc->then_expr_list);
+ g_slist_free_full (sc->then_expr_list, (GDestroyNotify) gda_sql_expr_free);
}
g_free (sc);
}
@@ -1397,8 +1394,7 @@ gda_sql_select_join_free (GdaSqlSelectJoin *join)
if (!join) return;
gda_sql_expr_free (join->expr);
- g_slist_foreach (join->use, (GFunc) gda_sql_field_free, NULL);
- g_slist_free (join->use);
+ g_slist_free_full (join->use, (GDestroyNotify) gda_sql_field_free);
g_free (join);
}
@@ -1559,12 +1555,10 @@ gda_sql_select_from_free (GdaSqlSelectFrom *from)
if (!from) return;
if (from->targets) {
- g_slist_foreach (from->targets, (GFunc) gda_sql_select_target_free, NULL);
- g_slist_free (from->targets);
+ g_slist_free_full (from->targets, (GDestroyNotify) gda_sql_select_target_free);
}
if (from->joins) {
- g_slist_foreach (from->joins, (GFunc) gda_sql_select_join_free, NULL);
- g_slist_free (from->joins);
+ g_slist_free_full (from->joins, (GDestroyNotify) gda_sql_select_join_free);
}
g_free (from);
diff --git a/libgda/sql-parser/gda-statement-struct-select.c b/libgda/sql-parser/gda-statement-struct-select.c
index e31bdb864..b18743369 100644
--- a/libgda/sql-parser/gda-statement-struct-select.c
+++ b/libgda/sql-parser/gda-statement-struct-select.c
@@ -70,19 +70,16 @@ _gda_sql_statement_select_free (gpointer stmt)
if (select->distinct_expr)
gda_sql_expr_free (select->distinct_expr);
if (select->expr_list) {
- g_slist_foreach (select->expr_list, (GFunc) gda_sql_select_field_free, NULL);
- g_slist_free (select->expr_list);
+ g_slist_free_full (select->expr_list, (GDestroyNotify) gda_sql_select_field_free);
}
gda_sql_select_from_free (select->from);
gda_sql_expr_free (select->where_cond);
if (select->group_by) {
- g_slist_foreach (select->group_by, (GFunc) gda_sql_expr_free, NULL);
- g_slist_free (select->group_by);
+ g_slist_free_full (select->group_by, (GDestroyNotify) gda_sql_expr_free);
}
gda_sql_expr_free (select->having_cond);
if (select->order_by) {
- g_slist_foreach (select->order_by, (GFunc) gda_sql_select_order_free, NULL);
- g_slist_free (select->order_by);
+ g_slist_free_full (select->order_by, (GDestroyNotify) gda_sql_select_order_free);
}
gda_sql_expr_free (select->limit_count);
gda_sql_expr_free (select->limit_offset);
diff --git a/libgda/sql-parser/gda-statement-struct-unknown.c
b/libgda/sql-parser/gda-statement-struct-unknown.c
index 4f1a7c8ab..baef5f6d3 100644
--- a/libgda/sql-parser/gda-statement-struct-unknown.c
+++ b/libgda/sql-parser/gda-statement-struct-unknown.c
@@ -64,8 +64,7 @@ static void
gda_sql_statement_unknown_free (gpointer stmt)
{
GdaSqlStatementUnknown *unknown = (GdaSqlStatementUnknown *) stmt;
- g_slist_foreach (unknown->expressions, (GFunc) gda_sql_expr_free, NULL);
- g_slist_free (unknown->expressions);
+ g_slist_free_full (unknown->expressions, (GDestroyNotify) gda_sql_expr_free);
g_free (unknown);
}
diff --git a/libgda/sql-parser/parser.y b/libgda/sql-parser/parser.y
index 8dba6373c..e97cbaa24 100644
--- a/libgda/sql-parser/parser.y
+++ b/libgda/sql-parser/parser.y
@@ -468,8 +468,7 @@ opt_on_conflict(O) ::= OR ID(V). {O = V;}
%type ins_extra_values {GSList*}
%destructor ins_extra_values {GSList *list;
for (list = $$; list; list = list->next) {
- g_slist_foreach ((GSList*) list->data, (GFunc) gda_sql_field_free, NULL);
- g_slist_free ((GSList*) list->data);
+ g_slist_free_full ((GSList*) list->data, (GDestroyNotify) gda_sql_field_free);
}
g_slist_free ($$);
}
@@ -477,12 +476,12 @@ ins_extra_values(E) ::= ins_extra_values(A) COMMA LP rexprlist(L) RP. {E = g_sli
ins_extra_values(E) ::= COMMA LP rexprlist(L) RP. {E = g_slist_append (NULL, g_slist_reverse (L));}
%type inscollist_opt {GSList*}
-%destructor inscollist_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_field_free, NULL); g_slist_free
($$);}}
+%destructor inscollist_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_field_free);}}
inscollist_opt(A) ::= . {A = NULL;}
inscollist_opt(A) ::= LP inscollist(X) RP. {A = X;}
%type inscollist {GSList*}
-%destructor inscollist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_field_free, NULL); g_slist_free ($$);}}
+%destructor inscollist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_field_free);}}
inscollist(A) ::= inscollist(X) COMMA fullname(Y). {GdaSqlField *field;
field = gda_sql_field_new (NULL);
gda_sql_field_take_name (field, Y);
@@ -596,12 +595,12 @@ limit_opt(A) ::= LIMIT expr(X) OFFSET expr(Y). {A.count = X; A.offset = Y;}
limit_opt(A) ::= LIMIT expr(X) COMMA expr(Y). {A.count = X; A.offset = Y;}
%type orderby_opt {GSList *}
-%destructor orderby_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_select_order_free, NULL);
g_slist_free ($$);}}
+%destructor orderby_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_order_free);}}
orderby_opt(A) ::= . {A = 0;}
orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;}
%type sortlist {GSList *}
-%destructor sortlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_select_order_free, NULL); g_slist_free
($$);}}
+%destructor sortlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_order_free);}}
sortlist(A) ::= sortlist(X) COMMA expr(Y) sortorder(Z). {GdaSqlSelectOrder *order;
order = gda_sql_select_order_new (NULL);
order->expr = Y;
@@ -627,7 +626,7 @@ having_opt(A) ::= . {A = NULL;}
having_opt(A) ::= HAVING expr(X). {A = X;}
%type groupby_opt {GSList*}
-%destructor groupby_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor groupby_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
groupby_opt(A) ::= . {A = 0;}
groupby_opt(A) ::= GROUP BY rnexprlist(X). {A = g_slist_reverse (X);}
@@ -658,7 +657,7 @@ seltablist(L) ::= stl_prefix(P) seltarget(T) on_cond(C) using_opt(U). {
}
%type using_opt {GSList*}
-%destructor using_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_field_free, NULL); g_slist_free ($$);}}
+%destructor using_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_field_free);}}
using_opt(U) ::= USING LP inscollist(L) RP. {U = L;}
using_opt(U) ::= . {U = NULL;}
@@ -709,10 +708,10 @@ seltarget(T) ::= LP compound(S) RP ID(A). {T = gda_sql_select_target_new (NULL);
gda_sql_select_target_take_select (T, S);
}
%type selcollist {GSList *}
-%destructor selcollist {g_slist_foreach ($$, (GFunc) gda_sql_select_field_free, NULL); g_slist_free ($$);}
+%destructor selcollist {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_field_free);}
%type sclp {GSList *}
-%destructor sclp {g_slist_foreach ($$, (GFunc) gda_sql_select_field_free, NULL); g_slist_free ($$);}
+%destructor sclp {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_field_free);}
sclp(A) ::= selcollist(X) COMMA. {A = X;}
sclp(A) ::= . {A = NULL;}
@@ -760,13 +759,13 @@ distinct(E) ::= DISTINCT ON expr(X). [OR] {E = g_new0 (Distinct, 1); E->distinct
// Non empty list of expressions
%type rnexprlist {GSList *}
-%destructor rnexprlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor rnexprlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
rnexprlist(L) ::= rnexprlist(E) COMMA expr(X). {L = g_slist_prepend (E, X);}
rnexprlist(L) ::= expr(E). {L = g_slist_append (NULL, E);}
// List of expressions
%type rexprlist {GSList *}
-%destructor rexprlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor rexprlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
rexprlist(L) ::= . {L = NULL;}
rexprlist(L) ::= rexprlist(E) COMMA expr(X). {L = g_slist_prepend (E, X);}
rexprlist(L) ::= expr(E). {L = g_slist_append (NULL, E);}
@@ -938,8 +937,8 @@ case_operand(A) ::= expr(X). {A = X;}
case_operand(A) ::= . {A = NULL;}
%type case_exprlist {CaseBody}
-%destructor case_exprlist {g_slist_foreach ($$.when_list, (GFunc) gda_sql_expr_free, NULL); g_slist_free
($$.when_list);
- g_slist_foreach ($$.then_list, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$.then_list);}
+%destructor case_exprlist {g_slist_free_full ($$.when_list, (GDestroyNotify) gda_sql_expr_free);
+ g_slist_free_full ($$.then_list, (GDestroyNotify) gda_sql_expr_free);}
case_exprlist(A) ::= case_exprlist(X) WHEN expr(Y) THEN expr(Z). {
A.when_list = g_slist_append (X.when_list, Y);
diff --git a/libgda/sqlite/virtual/gda-vconnection-data-model.c
b/libgda/sqlite/virtual/gda-vconnection-data-model.c
index d8ffb5c51..5f5e87f0b 100644
--- a/libgda/sqlite/virtual/gda-vconnection-data-model.c
+++ b/libgda/sqlite/virtual/gda-vconnection-data-model.c
@@ -554,22 +554,32 @@ _gda_vconnection_data_model_table_data_free (GdaVConnectionTableData *td)
if (td->real_model)
g_object_unref (td->real_model);
if (td->columns) {
- g_list_foreach (td->columns, (GFunc) g_object_unref, NULL);
- g_list_free (td->columns);
+ g_list_free_full (td->columns, (GDestroyNotify) g_object_unref);
+ td->columns = NULL;
}
g_free (td->table_name);
+ td->table_name = NULL;
g_free (td->unique_name);
- if (td->spec_free_func)
+ td->unique_name = NULL;
+ if (td->spec_free_func) {
td->spec_free_func (td->spec);
+ td->spec = NULL;
+ }
for (i = 0; i < PARAMS_NB; i++) {
- if (td->modif_params[i])
+ if (td->modif_params[i]) {
g_object_unref (td->modif_params[i]);
- if (td->modif_stmt[i])
+ td->modif_params[i] = NULL;
+ }
+ if (td->modif_stmt[i]) {
g_object_unref (td->modif_stmt[i]);
+ td->modif_stmt[i] = NULL;
+ }
}
- if (td->context.hash)
+ if (td->context.hash) {
g_hash_table_destroy (td->context.hash);
+ td->context.hash = NULL;
+ }
g_free (td);
}
diff --git a/libgda/thread-wrapper/itsignaler.c b/libgda/thread-wrapper/itsignaler.c
index 76541311a..45be69df5 100644
--- a/libgda/thread-wrapper/itsignaler.c
+++ b/libgda/thread-wrapper/itsignaler.c
@@ -875,7 +875,7 @@ its_source_dispatch (GSource *source, GSourceFunc callback, gpointer user_data)
{
ITSSource *isource = (ITSSource*) source;
ITSignalerFunc func;
- func = (ITSignalerFunc) callback;
+ func = IT_SIGNALER_FUNC (callback);
gboolean retval;
itsignaler_ref (isource->its);
@@ -919,7 +919,7 @@ itsignaler_add (ITSignaler *its, GMainContext *context, ITSignalerFunc func, gpo
if (!source)
return 0;
- g_source_set_callback (source, (GSourceFunc) func, data, notify);
+ g_source_set_callback (source, G_SOURCE_FUNC (func), data, notify);
id = g_source_attach (source, context);
g_source_unref (source);
diff --git a/libgda/thread-wrapper/itsignaler.h b/libgda/thread-wrapper/itsignaler.h
index d68f9fdbe..91cd9fbe4 100644
--- a/libgda/thread-wrapper/itsignaler.h
+++ b/libgda/thread-wrapper/itsignaler.h
@@ -49,6 +49,7 @@ GSource *itsignaler_create_source (ITSignaler *its);
* Returns: %FALSE if the source should be removed from the poll
*/
typedef gboolean (*ITSignalerFunc) (ITSignaler *its, gpointer user_data);
+#define IT_SIGNALER_FUNC(f) ((ITSignalerFunc) (int (*)(ITSignaler*, void*)) (f))
guint itsignaler_add (ITSignaler *its, GMainContext *context, ITSignalerFunc func, gpointer data,
GDestroyNotify notify);
gboolean itsignaler_remove (ITSignaler *its, GMainContext *context, guint id);
diff --git a/libgda/thread-wrapper/test-itsignaler.c b/libgda/thread-wrapper/test-itsignaler.c
index c35fdbd54..37daa2ed3 100644
--- a/libgda/thread-wrapper/test-itsignaler.c
+++ b/libgda/thread-wrapper/test-itsignaler.c
@@ -115,7 +115,7 @@ test1 (void)
CbData cbdata;
cbdata.counter = 0;
cbdata.loop = loop;
- g_source_set_callback (source, (GSourceFunc) source_callback, &cbdata, NULL);
+ g_source_set_callback (source, G_SOURCE_FUNC (source_callback), &cbdata, NULL);
g_source_attach (source, NULL);
GThread *th;
diff --git a/providers/oracle/parser.y b/providers/oracle/parser.y
index 2c43450da..9f33f5f7c 100644
--- a/providers/oracle/parser.y
+++ b/providers/oracle/parser.y
@@ -466,8 +466,7 @@ opt_on_conflict(O) ::= OR ID(V). {O = V;}
%type ins_extra_values {GSList*}
%destructor ins_extra_values {GSList *list;
for (list = $$; list; list = list->next) {
- g_slist_foreach ((GSList*) list->data, (GFunc) gda_sql_field_free, NULL);
- g_slist_free ((GSList*) list->data);
+ g_slist_free_full ((GSList*) list->data, (GDestroyNotify) gda_sql_field_free);
}
g_slist_free ($$);
}
@@ -475,12 +474,12 @@ ins_extra_values(E) ::= ins_extra_values(A) COMMA LP rexprlist(L) RP. {E = g_sli
ins_extra_values(E) ::= COMMA LP rexprlist(L) RP. {E = g_slist_append (NULL, g_slist_reverse (L));}
%type inscollist_opt {GSList*}
-%destructor inscollist_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_field_free, NULL); g_slist_free
($$);}}
+%destructor inscollist_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_field_free);}}
inscollist_opt(A) ::= . {A = NULL;}
inscollist_opt(A) ::= LP inscollist(X) RP. {A = X;}
%type inscollist {GSList*}
-%destructor inscollist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_field_free, NULL); g_slist_free ($$);}}
+%destructor inscollist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_field_free);}}
inscollist(A) ::= inscollist(X) COMMA fullname(Y). {GdaSqlField *field;
field = gda_sql_field_new (NULL);
gda_sql_field_take_name (field, Y);
@@ -594,12 +593,12 @@ limit_opt(A) ::= LIMIT expr(X) OFFSET expr(Y). {A.count = X; A.offset = Y;}
limit_opt(A) ::= LIMIT expr(X) COMMA expr(Y). {A.count = X; A.offset = Y;}
%type orderby_opt {GSList *}
-%destructor orderby_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_select_order_free, NULL);
g_slist_free ($$);}}
+%destructor orderby_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_order_free, NULL);}}
orderby_opt(A) ::= . {A = 0;}
orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;}
%type sortlist {GSList *}
-%destructor sortlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_select_order_free, NULL); g_slist_free
($$);}}
+%destructor sortlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_order_free);}}
sortlist(A) ::= sortlist(X) COMMA expr(Y) sortorder(Z). {GdaSqlSelectOrder *order;
order = gda_sql_select_order_new (NULL);
order->expr = Y;
@@ -625,7 +624,7 @@ having_opt(A) ::= . {A = NULL;}
having_opt(A) ::= HAVING expr(X). {A = X;}
%type groupby_opt {GSList*}
-%destructor groupby_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor groupby_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
groupby_opt(A) ::= . {A = 0;}
groupby_opt(A) ::= GROUP BY rnexprlist(X). {A = g_slist_reverse (X);}
@@ -656,7 +655,7 @@ seltablist(L) ::= stl_prefix(P) seltarget(T) on_cond(C) using_opt(U). {
}
%type using_opt {GSList*}
-%destructor using_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_field_free, NULL); g_slist_free ($$);}}
+%destructor using_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_field_free);}}
using_opt(U) ::= USING LP inscollist(L) RP. {U = L;}
using_opt(U) ::= . {U = NULL;}
@@ -704,10 +703,10 @@ seltarget(T) ::= LP compound(S) RP as(A). {T = gda_sql_select_target_new (NULL);
}
%type selcollist {GSList *}
-%destructor selcollist {g_slist_foreach ($$, (GFunc) gda_sql_select_field_free, NULL); g_slist_free ($$);}
+%destructor selcollist {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_field_free);}
%type sclp {GSList *}
-%destructor sclp {g_slist_foreach ($$, (GFunc) gda_sql_select_field_free, NULL); g_slist_free ($$);}
+%destructor sclp {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_field_free);}
sclp(A) ::= selcollist(X) COMMA. {A = X;}
sclp(A) ::= . {A = NULL;}
@@ -755,13 +754,13 @@ distinct(E) ::= DISTINCT ON expr(X). [OR] {E = g_new0 (Distinct, 1); E->distinct
// Non empty list of expressions
%type rnexprlist {GSList *}
-%destructor rnexprlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor rnexprlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
rnexprlist(L) ::= rnexprlist(E) COMMA expr(X). {L = g_slist_prepend (E, X);}
rnexprlist(L) ::= expr(E). {L = g_slist_append (NULL, E);}
// List of expressions
%type rexprlist {GSList *}
-%destructor rexprlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor rexprlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
rexprlist(L) ::= . {L = NULL;}
rexprlist(L) ::= rexprlist(E) COMMA expr(X). {L = g_slist_prepend (E, X);}
rexprlist(L) ::= expr(E). {L = g_slist_append (NULL, E);}
@@ -931,8 +930,8 @@ case_operand(A) ::= expr(X). {A = X;}
case_operand(A) ::= . {A = NULL;}
%type case_exprlist {CaseBody}
-%destructor case_exprlist {g_slist_foreach ($$.when_list, (GFunc) gda_sql_expr_free, NULL); g_slist_free
($$.when_list);
- g_slist_foreach ($$.then_list, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$.then_list);}
+%destructor case_exprlist {g_slist_free_full ($$.when_list, (GDestroyNotify) gda_sql_expr_free);
+ g_slist_free_full ($$.then_list, (GDestroyNotify) gda_sql_expr_free);}
case_exprlist(A) ::= case_exprlist(X) WHEN expr(Y) THEN expr(Z). {
A.when_list = g_slist_append (X.when_list, Y);
diff --git a/providers/skel-implementation/capi/gda-capi-ddl.c
b/providers/skel-implementation/capi/gda-capi-ddl.c
index c10d6d1c3..75805f30a 100644
--- a/providers/skel-implementation/capi/gda-capi-ddl.c
+++ b/providers/skel-implementation/capi/gda-capi-ddl.c
@@ -145,8 +145,7 @@ gda_capi_render_CREATE_TABLE (GdaServerProvider *provider, GdaConnection *cnc,
}
g_string_append_c (string, ')');
}
- g_slist_foreach (pkfields, (GFunc) g_free, NULL);
- g_slist_free (pkfields);
+ g_slist_free_full (pkfields, (GDestroyNotify) g_free);
g_string_append (string, ")");
diff --git a/providers/skel-implementation/capi/gda-capi-provider.c
b/providers/skel-implementation/capi/gda-capi-provider.c
index 4d3c2823a..c69f1e704 100644
--- a/providers/skel-implementation/capi/gda-capi-provider.c
+++ b/providers/skel-implementation/capi/gda-capi-provider.c
@@ -1295,8 +1295,7 @@ gda_capi_provider_statement_execute (GdaServerProvider *provider, GdaConnection
last_inserted_row,
error);
/* clear original @param_ids and restore copied one */
- g_slist_foreach (prep_param_ids, (GFunc) g_free, NULL);
- g_slist_free (prep_param_ids);
+ g_slist_free_full (prep_param_ids, (GDestroyNotify) g_free);
gda_pstmt_set_param_ids (gtps, copied_param_ids);
diff --git a/providers/skel-implementation/capi/parser.y b/providers/skel-implementation/capi/parser.y
index 8003f5ef9..75f0cdf09 100644
--- a/providers/skel-implementation/capi/parser.y
+++ b/providers/skel-implementation/capi/parser.y
@@ -466,8 +466,7 @@ opt_on_conflict(O) ::= OR ID(V). {O = V;}
%type ins_extra_values {GSList*}
%destructor ins_extra_values {GSList *list;
for (list = $$; list; list = list->next) {
- g_slist_foreach ((GSList*) list->data, (GFunc) gda_sql_field_free, NULL);
- g_slist_free ((GSList*) list->data);
+ g_slist_free_full ((GSList*) list->data, (GDestroyNotify) gda_sql_field_free);
}
g_slist_free ($$);
}
@@ -475,12 +474,12 @@ ins_extra_values(E) ::= ins_extra_values(A) COMMA LP rexprlist(L) RP. {E = g_sli
ins_extra_values(E) ::= COMMA LP rexprlist(L) RP. {E = g_slist_append (NULL, g_slist_reverse (L));}
%type inscollist_opt {GSList*}
-%destructor inscollist_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_field_free, NULL); g_slist_free
($$);}}
+%destructor inscollist_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_field_free);}}
inscollist_opt(A) ::= . {A = NULL;}
inscollist_opt(A) ::= LP inscollist(X) RP. {A = X;}
%type inscollist {GSList*}
-%destructor inscollist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_field_free, NULL); g_slist_free ($$);}}
+%destructor inscollist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_field_free);}}
inscollist(A) ::= inscollist(X) COMMA fullname(Y). {GdaSqlField *field;
field = gda_sql_field_new (NULL);
gda_sql_field_take_name (field, Y);
@@ -594,12 +593,12 @@ limit_opt(A) ::= LIMIT expr(X) OFFSET expr(Y). {A.count = X; A.offset = Y;}
limit_opt(A) ::= LIMIT expr(X) COMMA expr(Y). {A.count = X; A.offset = Y;}
%type orderby_opt {GSList *}
-%destructor orderby_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_select_order_free, NULL);
g_slist_free ($$);}}
+%destructor orderby_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_order_free);}}
orderby_opt(A) ::= . {A = 0;}
orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;}
%type sortlist {GSList *}
-%destructor sortlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_select_order_free, NULL); g_slist_free
($$);}}
+%destructor sortlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_order_free);}}
sortlist(A) ::= sortlist(X) COMMA expr(Y) sortorder(Z). {GdaSqlSelectOrder *order;
order = gda_sql_select_order_new (NULL);
order->expr = Y;
@@ -625,7 +624,7 @@ having_opt(A) ::= . {A = NULL;}
having_opt(A) ::= HAVING expr(X). {A = X;}
%type groupby_opt {GSList*}
-%destructor groupby_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor groupby_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
groupby_opt(A) ::= . {A = 0;}
groupby_opt(A) ::= GROUP BY rnexprlist(X). {A = g_slist_reverse (X);}
@@ -656,7 +655,7 @@ seltablist(L) ::= stl_prefix(P) seltarget(T) on_cond(C) using_opt(U). {
}
%type using_opt {GSList*}
-%destructor using_opt {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_field_free, NULL); g_slist_free ($$);}}
+%destructor using_opt {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_field_free);}}
using_opt(U) ::= USING LP inscollist(L) RP. {U = L;}
using_opt(U) ::= . {U = NULL;}
@@ -704,10 +703,10 @@ seltarget(T) ::= LP compound(S) RP as(A). {T = gda_sql_select_target_new (NULL);
}
%type selcollist {GSList *}
-%destructor selcollist {g_slist_foreach ($$, (GFunc) gda_sql_select_field_free, NULL); g_slist_free ($$);}
+%destructor selcollist {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_field_free);}
%type sclp {GSList *}
-%destructor sclp {g_slist_foreach ($$, (GFunc) gda_sql_select_field_free, NULL); g_slist_free ($$);}
+%destructor sclp {g_slist_free_full ($$, (GDestroyNotify) gda_sql_select_field_free);}
sclp(A) ::= selcollist(X) COMMA. {A = X;}
sclp(A) ::= . {A = NULL;}
@@ -755,13 +754,13 @@ distinct(E) ::= DISTINCT ON expr(X). [OR] {E = g_new0 (Distinct, 1); E->distinct
// Non empty list of expressions
%type rnexprlist {GSList *}
-%destructor rnexprlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor rnexprlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
rnexprlist(L) ::= rnexprlist(E) COMMA expr(X). {L = g_slist_prepend (E, X);}
rnexprlist(L) ::= expr(E). {L = g_slist_append (NULL, E);}
// List of expressions
%type rexprlist {GSList *}
-%destructor rexprlist {if ($$) {g_slist_foreach ($$, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$);}}
+%destructor rexprlist {if ($$) {g_slist_free_full ($$, (GDestroyNotify) gda_sql_expr_free);}}
rexprlist(L) ::= . {L = NULL;}
rexprlist(L) ::= rexprlist(E) COMMA expr(X). {L = g_slist_prepend (E, X);}
rexprlist(L) ::= expr(E). {L = g_slist_append (NULL, E);}
@@ -931,8 +930,8 @@ case_operand(A) ::= expr(X). {A = X;}
case_operand(A) ::= . {A = NULL;}
%type case_exprlist {CaseBody}
-%destructor case_exprlist {g_slist_foreach ($$.when_list, (GFunc) gda_sql_expr_free, NULL); g_slist_free
($$.when_list);
- g_slist_foreach ($$.then_list, (GFunc) gda_sql_expr_free, NULL); g_slist_free ($$.then_list);}
+%destructor case_exprlist {g_slist_free_full ($$.when_list, (GDestroyNotify) gda_sql_expr_free);
+ g_slist_free_full ($$.then_list, (GDestroyNotify) gda_sql_expr_free);}
case_exprlist(A) ::= case_exprlist(X) WHEN expr(Y) THEN expr(Z). {
A.when_list = g_slist_append (X.when_list, Y);
diff --git a/providers/skel-implementation/models/gda-models-provider.c
b/providers/skel-implementation/models/gda-models-provider.c
index 0cfd94a77..d4b24794d 100644
--- a/providers/skel-implementation/models/gda-models-provider.c
+++ b/providers/skel-implementation/models/gda-models-provider.c
@@ -31,8 +31,7 @@
#include <libgda/gda-debug-macros.h>
static void gda_models_provider_class_init (GdaModelsProviderClass *klass);
-static void gda_models_provider_init (GdaModelsProvider *provider,
- GdaModelsProviderClass *klass);
+static void gda_models_provider_init (GdaModelsProvider *provider);
static void gda_models_provider_finalize (GObject *object);
static const gchar *gda_models_provider_get_name (GdaServerProvider *provider);
@@ -44,8 +43,6 @@ static gboolean gda_models_provider_close_connection (GdaServerProvider *provide
static const gchar *gda_models_provider_get_server_version (GdaServerProvider *provider,
GdaConnection *cnc);
-static GObjectClass *parent_class = NULL;
-
/*
* private connection data destroy
*/
@@ -88,13 +85,13 @@ GdaServerProviderBase data_model_base_functions = {
NULL, NULL, NULL, NULL, /* padding */
};
+G_DEFINE_TYPE(GdaModelsProvider, gda_models_provider, GDA_TYPE_VPROVIDER_DATA_MODEL)
+
static void
gda_models_provider_class_init (GdaModelsProviderClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
- parent_class = g_type_class_peek_parent (klass);
-
/* set virtual functions */
gda_server_provider_set_impl_functions (GDA_SERVER_PROVIDER_CLASS (klass),
GDA_SERVER_PROVIDER_FUNCTIONS_BASE,
@@ -104,8 +101,7 @@ gda_models_provider_class_init (GdaModelsProviderClass *klass)
}
static void
-gda_models_provider_init (G_GNUC_UNUSED GdaModelsProvider *pg_prv,
- G_GNUC_UNUSED GdaModelsProviderClass *klass)
+gda_models_provider_init (G_GNUC_UNUSED GdaModelsProvider *pg_prv)
{
/* initialization of provider instance is to add here */
TO_IMPLEMENT;
@@ -119,34 +115,7 @@ gda_models_provider_finalize (GObject *object)
g_return_if_fail (GDA_IS_MODELS_PROVIDER (pg_prv));
/* chain to parent class */
- parent_class->finalize(object);
-}
-
-GType
-gda_models_provider_get_type (void)
-{
- static GType type = 0;
-
- if (G_UNLIKELY (type == 0)) {
- static GMutex registering;
- static GTypeInfo info = {
- sizeof (GdaModelsProviderClass),
- (GBaseInitFunc) NULL,
- (GBaseFinalizeFunc) NULL,
- (GClassInitFunc) gda_models_provider_class_init,
- NULL, NULL,
- sizeof (GdaModelsProvider),
- 0,
- (GInstanceInitFunc) gda_models_provider_init,
- 0
- };
- g_mutex_lock (®istering);
- if (type == 0)
- type = g_type_register_static (GDA_TYPE_VPROVIDER_DATA_MODEL, "GdaModelsProvider",
&info, 0);
- g_mutex_unlock (®istering);
- }
-
- return type;
+ G_OBJECT_CLASS (gda_models_provider_parent_class)->finalize (object);
}
/*
@@ -247,7 +216,7 @@ gda_models_provider_close_connection (GdaServerProvider *provider, GdaConnection
/* link to parent implementation */
GdaServerProviderBase *parent_functions;
- parent_functions = gda_server_provider_get_impl_functions_for_class (parent_class,
GDA_SERVER_PROVIDER_FUNCTIONS_BASE);
+ parent_functions = gda_server_provider_get_impl_functions_for_class
(gda_models_provider_parent_class, GDA_SERVER_PROVIDER_FUNCTIONS_BASE);
return parent_functions->close_connection (provider, cnc);
}
diff --git a/providers/skel-implementation/models/gda-models-provider.h
b/providers/skel-implementation/models/gda-models-provider.h
index b3c9d46e3..3238c0d89 100644
--- a/providers/skel-implementation/models/gda-models-provider.h
+++ b/providers/skel-implementation/models/gda-models-provider.h
@@ -4,6 +4,7 @@
* AUTHORS:
* TO_ADD: your name and email
* Vivien Malerba <malerba gnome-db org>
+ * Daniel Espinosa <esodan gmail com>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -26,17 +27,7 @@
#include <virtual/gda-vprovider-data-model.h>
#define GDA_TYPE_MODELS_PROVIDER (gda_models_provider_get_type())
-#define GDA_MODELS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_CAST (obj, GDA_TYPE_MODELS_PROVIDER,
GdaModelsProvider))
-#define GDA_MODELS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST (klass, GDA_TYPE_MODELS_PROVIDER,
GdaModelsProviderClass))
-#define GDA_IS_MODELS_PROVIDER(obj) (G_TYPE_CHECK_INSTANCE_TYPE (obj, GDA_TYPE_MODELS_PROVIDER))
-#define GDA_IS_MODELS_PROVIDER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDA_TYPE_MODELS_PROVIDER))
-
-typedef struct _GdaModelsProvider GdaModelsProvider;
-typedef struct _GdaModelsProviderClass GdaModelsProviderClass;
-
-struct _GdaModelsProvider {
- GdaVproviderDataModel provider;
-};
+G_DECLARE_DERIVABLE_TYPE(GdaModelsProvider, gda_models_provider, GDA, MODELS_PROVIDER, GdaVproviderDataModel)
struct _GdaModelsProviderClass {
GdaVproviderDataModelClass parent_class;
@@ -44,7 +35,6 @@ struct _GdaModelsProviderClass {
G_BEGIN_DECLS
-GType gda_models_provider_get_type (void) G_GNUC_CONST;
G_END_DECLS
diff --git a/tests/meta-store/common.c b/tests/meta-store/common.c
index fb36f332a..516d6710d 100644
--- a/tests/meta-store/common.c
+++ b/tests/meta-store/common.c
@@ -224,8 +224,7 @@ common_declare_expected_change (const gchar *table_name, GdaMetaStoreChangeType
g_print ("Received no change but EXPECTED GdaMetaStoreChange: %s", estr);
exit (EXIT_FAILURE);
}
- g_slist_foreach (expected_changes, (GFunc) g_free, NULL);
- g_slist_free (expected_changes);
+ g_slist_free_full (expected_changes, (GDestroyNotify) g_free);
expected_changes = NULL;
}
else {
diff --git a/tests/multi-threading/common.c b/tests/multi-threading/common.c
index 747463996..4810c4758 100644
--- a/tests/multi-threading/common.c
+++ b/tests/multi-threading/common.c
@@ -83,8 +83,7 @@ create_sqlite_db (const gchar *dir, const gchar *dbname, const gchar *sqlfile, G
if (g_slist_length (list) != g_slist_length ((GSList *) stmt_list))
retval = FALSE;
- g_slist_foreach (list, (GFunc) g_object_unref, NULL);
- g_slist_free (list);
+ g_slist_free_full (list, (GDestroyNotify) g_object_unref);
g_assert (gda_connection_close (cnc, NULL));
g_object_unref (cnc);
diff --git a/tests/value-holders/check_set.c b/tests/value-holders/check_set.c
index 8272cf78d..03d636f3f 100644
--- a/tests/value-holders/check_set.c
+++ b/tests/value-holders/check_set.c
@@ -412,8 +412,7 @@ emitted_signal_add (EmittedSignal *es)
static void
emitted_signals_reset (void)
{
- g_slist_foreach (signals_list, (GFunc) g_free, NULL);
- g_slist_free (signals_list);
+ g_slist_free_full (signals_list, (GDestroyNotify) g_free);
signals_list = NULL;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]