GHashTable *fields_updated;
} RecordUpdated;
+G_DEFINE_BOXED_TYPE (ZakAuditDatasource, zak_audit_datasource, zak_audit_datasource_copy, zak_audit_datasource_free)
+G_DEFINE_BOXED_TYPE (ZakAuditTable, zak_audit_table, zak_audit_table_copy, zak_audit_table_free)
+G_DEFINE_BOXED_TYPE (ZakAuditField, zak_audit_field, zak_audit_field_copy, zak_audit_field_free)
+
+static void zak_audit_dispose (GObject *gobject);
+static void zak_audit_finalize (GObject *gobject);
+
static void zak_audit_class_init (ZakAuditClass *klass);
static void zak_audit_init (ZakAudit *zak_audit);
-static ZakAudit *zak_audit_new_ (void);
static gboolean load_fields (ZakAudit *zak_audit,
ZakAuditDatasource *datasource,
ZakAuditTable *table);
object_class->set_property = zak_audit_set_property;
object_class->get_property = zak_audit_get_property;
+ object_class->dispose = zak_audit_dispose;
+ object_class->finalize = zak_audit_finalize;
}
static void
}
}
+static void
+zak_audit_dispose (GObject *gobject)
+{
+ ZakAudit *zak_audit = ZAK_AUDIT (gobject);
+ ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit);
+
+ /* In dispose(), you are supposed to free all types referenced from this
+ * object which might themselves hold a reference to self. Generally,
+ * the most simple solution is to unref all members on which you own a
+ * reference.
+ */
+
+ /* dispose() might be called multiple times, so we must guard against
+ * calling g_object_unref() on an invalid GObject by setting the member
+ * NULL; g_clear_object() does this for us.
+ */
+ /*g_clear_object (&priv->input_stream);*/
+ gdaex_free (priv->gdaex);
+
+ /* Always chain up to the parent class; there is no need to check if
+ * the parent class implements the dispose() virtual function: it is
+ * always guaranteed to do so
+ */
+ G_OBJECT_CLASS (zak_audit_parent_class)->dispose (gobject);
+}
+
+static void
+zak_audit_finalize (GObject *gobject)
+{
+ ZakAudit *zak_audit = ZAK_AUDIT (gobject);
+ ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit);
+
+ g_list_free_full (priv->datasources, zak_audit_datasource_free);
+
+ /* Always chain up to the parent class; as with dispose(), finalize()
+ * is guaranteed to exist on the parent's class virtual function table
+ */
+ G_OBJECT_CLASS (zak_audit_parent_class)->finalize (gobject);
+}
+
/* PUBLIC */
/**
* zak_audit_new_with_datasources:
{
ZakAuditPrivate *priv = ZAK_AUDIT_GET_PRIVATE (zak_audit);
- gdaex_free (priv->gdaex);
-
g_object_unref (zak_audit);
}
zak_audit_table_free (ZakAuditTable *table)
{
g_free (table->name);
- g_list_free_full (table->fields, g_free);
+ g_list_free_full (table->fields, zak_audit_field_free);
g_free (table->fields_sql);
- g_list_free_full (table->keys, g_free);
+ g_list_free_full (table->keys, zak_audit_field_free);
g_free (table->keys_sql);
g_slice_free (ZakAuditTable, table);
}
g_free (datasource->name);
g_free (datasource->cnc_string);
g_object_unref (datasource->gdaex);
- g_list_free_full (datasource->tables, g_free);
+ g_list_free_full (datasource->tables, zak_audit_table_free);
g_slice_free (ZakAuditDatasource, datasource);
}