[libgda] Compilation corrections after API changes



commit c20c79c16b9097e23aa4597561a7cdb3b4a348b2
Author: Vivien Malerba <malerba gnome-db org>
Date:   Sun May 15 21:38:48 2016 +0200

    Compilation corrections after API changes

 doc/C/libgda-sections.txt                        |   21 ++++-
 libgda/dir-blob-op.c                             |    6 +-
 libgda/gda-meta-store.c                          |    4 +-
 libgda/gda-value.c                               |  105 +++++++++++++++-------
 libgda/gda-value.h                               |   13 ++--
 libgda/libgda.symbols                            |    8 ++
 libgda/sqlite/virtual/gda-vprovider-data-model.c |    4 +-
 providers/firebird/gda-firebird-blob-op.c        |   13 +---
 providers/jdbc/GdaInputStream.c                  |   38 +++++----
 providers/jdbc/GdaJValue.c                       |   44 +++++----
 providers/jdbc/gda-jdbc-blob-op.c                |   36 ++++----
 providers/ldap/gda-ldap-util.c                   |   15 +--
 providers/mdb/gda-mdb-provider.c                 |   15 ++--
 providers/mysql/gda-mysql-blob-op.c              |   11 +--
 providers/mysql/gda-mysql-provider.c             |   32 ++++---
 providers/mysql/gda-mysql-recordset.c            |   17 ++--
 providers/oracle/gda-oracle-blob-op.c            |   27 +++----
 providers/oracle/gda-oracle-util.c               |   23 +++---
 tools/browser/ldap-browser/entry-properties.c    |   18 ++--
 19 files changed, 248 insertions(+), 202 deletions(-)
---
diff --git a/doc/C/libgda-sections.txt b/doc/C/libgda-sections.txt
index 64aa99b..ce0b269 100644
--- a/doc/C/libgda-sections.txt
+++ b/doc/C/libgda-sections.txt
@@ -895,24 +895,35 @@ gda_value_isa
 <SUBSECTION>
 GdaBinary
 gda_value_new_binary
-gda_value_get_binary
 gda_value_set_binary
 gda_value_take_binary
+gda_value_get_binary
+gda_binary_get_type
+gda_binary_new
+gda_binary_set_data
+gda_binary_reset_data
+gda_binary_get_data
+gda_binary_get_size
 gda_binary_copy
 gda_binary_free
 gda_binary_to_string
 gda_string_to_binary
 <SUBSECTION>
 GdaBlob
-gda_value_new_blob
-gda_value_new_blob_from_file
+gda_blob_get_type
+gda_blob_new
+gda_blob_get_binary
+gda_blob_get_op
+gda_blob_set_op
 gda_blob_copy
 gda_blob_free
-gda_value_get_blob
+gda_value_new_blob
+gda_value_new_blob_from_file
 gda_value_set_blob
 gda_value_take_blob
-gda_blob_set_op
+gda_value_get_blob
 gda_blob_to_string
+gda_string_to_blob
 <SUBSECTION>
 GdaGeometricPoint
 gda_geometricpoint_copy
diff --git a/libgda/dir-blob-op.c b/libgda/dir-blob-op.c
index 617d871..f311bfb 100644
--- a/libgda/dir-blob-op.c
+++ b/libgda/dir-blob-op.c
@@ -204,7 +204,7 @@ gda_dir_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size)
        gda_binary_reset_data (bin);
        buffer = g_new0 (guchar, size);
        nread = fread ((char *) (buffer), 1, size, file);
-       gda_binary_set_data (bin, buffer, nread);
+       gda_binary_take_data (bin, buffer, nread);
        fclose (file);
 
        return nread;
@@ -252,8 +252,7 @@ gda_dir_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
                     nread = gda_blob_op_read (gda_blob_get_op (tmpblob), tmpblob, nbwritten, buf_size)) {
                        GdaBinary *bin = gda_blob_get_binary (tmpblob);
                        glong tmp_written;
-                       guchar *buffer;
-                       tmp_written = fwrite ((char *) (buffer), sizeof (guchar), gda_binary_get_size (bin), 
file);
+                       tmp_written = fwrite ((char *) gda_binary_get_data (bin), sizeof (guchar), 
gda_binary_get_size (bin), file);
                        if (tmp_written < gda_binary_get_size (bin)) {
                                /* error writing stream */
                                fclose (file);
@@ -265,6 +264,7 @@ gda_dir_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
                                /* nothing more to read */
                                break;
                }
+
                fclose (file);
                gda_blob_free (tmpblob);
        }
diff --git a/libgda/gda-meta-store.c b/libgda/gda-meta-store.c
index f06f977..969d371 100644
--- a/libgda/gda-meta-store.c
+++ b/libgda/gda-meta-store.c
@@ -71,10 +71,8 @@
 // This is a copy of the macro located at gda-value.h
 #define l_g_value_unset(val) G_STMT_START{ if (G_IS_VALUE (val)) g_value_unset (val); }G_STMT_END
 
-// GdaMetaStoreChange
-
+/* change general information */
 typedef struct _GdaMetaStoreChange {
-       /* change general information */
        GdaMetaStoreChangeType  c_type;
        gchar                  *table_name;
        GHashTable             *keys; /* key = ('+' or '-') and a column position in @table (string) starting 
at 0, 
diff --git a/libgda/gda-value.c b/libgda/gda-value.c
index c1442f7..6dc0650 100644
--- a/libgda/gda-value.c
+++ b/libgda/gda-value.c
@@ -2,7 +2,7 @@
  * Copyright (C) 2001 - 2003 Rodrigo Moya <rodrigo gnome-db org>
  * Copyright (C) 2002 - 2003 Gonzalo Paniagua Javier <gonzalo gnome-db org>
  * Copyright (C) 2002 Holger Thon <holger thon gnome-db org>
- * Copyright (C) 2002 - 2015 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2002 - 2016 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2002 Zbigniew Chyla <cyba gnome pl>
  * Copyright (C) 2003 Akira TAGOH <tagoh gnome-db org>
  * Copyright (C) 2003 Danilo Schoeneberg <dschoene src gnome org>
@@ -430,7 +430,7 @@ binary_to_string (const GValue *src, GValue *dest)
        g_return_if_fail (G_VALUE_HOLDS_STRING (dest) &&
                          GDA_VALUE_HOLDS_BINARY (src));
 
-       str = gda_binary_to_string (gda_value_get_binary ((GValue *) src), 0);
+       str = gda_binary_to_string (gda_value_get_binary (src), 0);
 
        g_value_take_string (dest, str);
 }
@@ -497,69 +497,99 @@ blob_to_string (const GValue *src, GValue *dest)
  * Creates a new #GdaBinary coping data.
  *
  * Returns: (transfer full): the newly created #GdaBinary.
+ *
+ * Since: 6.0
  */
 GdaBinary*
 gda_binary_new (void)
 {
        GdaBinary *binary = g_new0 (GdaBinary, 1);
 
-  binary->data = NULL;
-  binary->binary_length = 0;
+       binary->data = NULL;
+       binary->binary_length = 0;
 
-  return (GdaBinary*) binary;
+       return (GdaBinary*) binary;
 }
 
 /**
  * gda_binary_set_data:
+ * @binary: a #GdaBinay pointer
  * @val: (array length=size): value to be copied by #GdaBinary.
  * @size: the size of the memory pool pointer to by @val.
  *
  * Set binary data to a #GdaBinary, holding a copy of the data.
  *
  * Returns: (transfer full): the newly created #GdaBinary.
+ *
+ * Since: 6.0
  */
 void
 gda_binary_set_data (GdaBinary *binary, const guchar *val, glong size)
 {
        g_return_if_fail (binary);
        g_return_if_fail (val);
-  if (binary->data != NULL)
-    g_free (binary->data);
-  binary->data = g_memdup (val, size);
-  binary->binary_length = size;
+       if (binary->data)
+               g_free (binary->data);
+       binary->data = g_memdup (val, size);
+       binary->binary_length = size;
+}
+
+/**
+ * gda_binary_take_data:
+ * @val: (array length=size): value to be taken by #GdaBinary.
+ * @size: the size of the memory pool pointer to by @val.
+ *
+ * Set binary data to a #GdaBinary, directly holding @val (no copy made).
+ *
+ * Returns: (transfer full): the newly created #GdaBinary.
+ */
+void
+gda_binary_take_data (GdaBinary *binary, guchar *val, glong size)
+{
+       g_return_if_fail (binary);
+       g_return_if_fail (val);
+       if (binary->data)
+               g_free (binary->data);
+       binary->data = val;
+       binary->binary_length = size;
 }
 
 
 /**
  * gda_binary_get_data:
+ * @binary: a #GdaBinay pointer
  *
  * Returns: (transfer none): associated data to #GdaBinary.
+ *
+ * Since: 6.0
  */
 gpointer
 gda_binary_get_data (GdaBinary *binary)
 {
        g_return_val_if_fail (binary, NULL);
 
-  return binary->data;
+       return binary->data;
 }
 
 
 
 /**
  * gda_binary_reset_data:
+ * @binary: a #GdaBinay pointer
  *
  * Frees data referenced by #GdaBinary
  *
+ * Since: 6.0
  */
 void
 gda_binary_reset_data (GdaBinary *binary)
 {
        g_return_if_fail (binary);
 
-  if (binary->data != NULL)
-    g_free (binary->data);
-  binary->data = NULL;
-  binary->binary_length = 0;
+       if (binary->data != NULL)
+               g_free (binary->data);
+       binary->data = NULL;
+       binary->binary_length = 0;
 }
 
 
@@ -567,13 +597,15 @@ gda_binary_reset_data (GdaBinary *binary)
  * gda_binary_get_size:
  *
  * Returns: size of associated data to #GdaBinary or -1 in case of error.
+ *
+ * Since: 6.0
  */
 glong
 gda_binary_get_size (GdaBinary *binary)
 {
        g_return_val_if_fail (binary, -1);
 
-  return binary->binary_length;
+       return binary->binary_length;
 }
 
 
@@ -612,13 +644,13 @@ gda_binary_free (GdaBinary *binary)
        g_return_if_fail (binary);
 
        if (binary->data)
-         g_free (binary->data);
+               g_free (binary->data);
        g_free (binary);
 }
 
 /**
  * gda_value_new_binary: (skip)
- * @val: value to set for the new #GValue.
+ * @val: (transfert full): value to set for the new #GValue.
  * @size: the size of the memory pool pointer to by @val.
  *
  * Makes a new #GValue of type #GDA_TYPE_BINARY with value @val.
@@ -636,7 +668,7 @@ gda_value_new_binary (const guchar *val, glong size)
        /* We use the const on the function parameter to make this clearer,
         * but it would be awkward to keep the const in the struct.
          */
-        binary.data = (guchar*)val;
+        binary.data = (guchar*) val;
         binary.binary_length = size;
 
         value = g_new0 (GValue, 1);
@@ -681,8 +713,10 @@ gda_blob_get_type (void)
  * gda_blob_new:
  *
  * Creates a new #GdaBlob.
-
+ *
  * Returns: (transfer full): a newly allocated #GdaBlob.
+ *
+ * Since: 6.0
  */
 GdaBlob*
 gda_blob_new (void)
@@ -695,8 +729,11 @@ gda_blob_new (void)
 
 /**
  * gda_blob_get_binary:
+ * @blob: a #GdaBlob pointer
  *
  * Returns: (transfer none): associated #GdaBinary.
+ *
+ * Since: 6.0
  */
 GdaBinary*
 gda_blob_get_binary (GdaBlob *blob)
@@ -708,8 +745,11 @@ gda_blob_get_binary (GdaBlob *blob)
 
 /**
  * gda_blob_get_op:
+ * @blob: a #GdaBlob pointer
  *
  * Returns: (transfer none): associated #GdaBlobOp.
+ *
+ * Since: 6.0
  */
 GdaBlobOp*
 gda_blob_get_op (GdaBlob *blob)
@@ -738,11 +778,13 @@ gda_blob_copy (GdaBlob *src)
 
        copy = g_new0 (GdaBlob, 1);
        copy->data = gda_binary_new ();
-       if (src->data == NULL) return copy;
+       if (! src->data)
+               return copy;
+
        if (src->data->data)
-         gda_binary_set_data (copy->data,
-                             gda_binary_get_data (src->data),
-                             gda_binary_get_size (src->data));
+               gda_binary_set_data (copy->data,
+                                    gda_binary_get_data (src->data),
+                                    gda_binary_get_size (src->data));
        gda_blob_set_op (copy, src->op);
 
        return (GdaBlob*) copy;
@@ -772,7 +814,7 @@ gda_blob_free (GdaBlob *blob)
  * @blob: a #GdaBlob value
  * @op: (allow-none): a #GdaBlobOp object, or %NULL
  *
- * correctly assigns @op to @blob
+ * Correctly assigns @op to @blob (increases @op's reference count)
  */
 void
 gda_blob_set_op (GdaBlob *blob, GdaBlobOp *op)
@@ -1736,11 +1778,11 @@ gda_value_new_blob (const guchar *val, glong size)
        blob = gda_blob_new ();
        bin = gda_blob_get_binary (blob);
        gda_binary_set_data (bin, val, size);
-  value = g_new0 (GValue, 1);
+       value = g_new0 (GValue, 1);
        g_value_init (value, GDA_TYPE_BLOB);
-  g_value_take_boxed (value, blob);
+       g_value_take_boxed (value, blob);
 
-  return value;
+       return value;
 }
 
 /**
@@ -2140,7 +2182,7 @@ gda_value_copy (const GValue *value)
  * Returns: (transfer none): the value stored in @value.
  */
 GdaBinary *
-gda_value_get_binary (GValue *value)
+gda_value_get_binary (const GValue *value)
 {
        GdaBinary *val;
 
@@ -2169,9 +2211,8 @@ gda_value_set_binary (GValue *value, GdaBinary *binary)
        g_value_init (value, GDA_TYPE_BINARY);
        if (binary)
                g_value_set_boxed (value, binary);
-       else {
+       else
                g_value_set_boxed (value, gda_binary_new ());
-       }
 }
 
 /**
@@ -2641,8 +2682,8 @@ gda_value_differ (const GValue *value1, const GValue *value2)
 
        /* general case */
        if (type == GDA_TYPE_BINARY) {
-               const GdaBinary *binary1 = gda_value_get_binary (value1);
-               const GdaBinary *binary2 = gda_value_get_binary (value2);
+               const GdaBinary *binary1 = gda_value_get_binary ((GValue*) value1);
+               const GdaBinary *binary2 = gda_value_get_binary ((GValue*) value2);
                if (binary1 && binary2 && (binary1->binary_length == binary2->binary_length))
                        return bcmp (binary1->data, binary2->data, binary1->binary_length);
                else
diff --git a/libgda/gda-value.h b/libgda/gda-value.h
index b74b208..3088d3a 100644
--- a/libgda/gda-value.h
+++ b/libgda/gda-value.h
@@ -141,7 +141,7 @@ typedef struct _GdaBinary GdaBinary;
 #define GDA_VALUE_HOLDS_BINARY(value)          G_VALUE_HOLDS(value, GDA_TYPE_BINARY)
 
 GValue*                           gda_value_new_binary (const guchar *val, glong size);
-GdaBinary*                        gda_value_get_binary (GValue *value);
+GdaBinary*                        gda_value_get_binary (const GValue *value);
 void                              gda_value_set_binary (GValue *value, GdaBinary *binary);
 void                              gda_value_take_binary (GValue *value, GdaBinary *binary);
 
@@ -152,6 +152,7 @@ glong                             gda_binary_get_size (GdaBinary* binary);
 gpointer                          gda_binary_get_data (GdaBinary* binary);
 void                              gda_binary_reset_data (GdaBinary* binary);
 void                              gda_binary_set_data (GdaBinary *binary, const guchar *val, glong size);
+void                              gda_binary_take_data (GdaBinary *binary, guchar *val, glong size);
 GdaBinary*                        gda_binary_copy (GdaBinary *src);
 void                              gda_binary_free (GdaBinary *binary);
 
@@ -235,22 +236,22 @@ gboolean                          gda_value_is_number (const GValue *value);
 GValue                           *gda_value_copy (const GValue *value);
 
 
-const GdaBlob           *gda_value_get_blob (const GValue *value);
+const GdaBlob                    *gda_value_get_blob (const GValue *value);
 void                              gda_value_set_blob (GValue *value, const GdaBlob *blob);
 void                              gda_value_take_blob (GValue *value, GdaBlob *blob);
 
-const GdaGeometricPoint *gda_value_get_geometric_point (const GValue *value);
+const GdaGeometricPoint          *gda_value_get_geometric_point (const GValue *value);
 void                              gda_value_set_geometric_point (GValue *value, const GdaGeometricPoint 
*val);
 void                              gda_value_set_null (GValue *value);
-const GdaNumeric        *gda_value_get_numeric (const GValue *value);
+const GdaNumeric                 *gda_value_get_numeric (const GValue *value);
 void                              gda_value_set_numeric (GValue *value, const GdaNumeric *val);
 gshort                            gda_value_get_short (const GValue *value);
 void                              gda_value_set_short (GValue *value, const gshort val);
 gushort                           gda_value_get_ushort (const GValue *value);
 void                              gda_value_set_ushort (GValue *value, const gushort val);
-const GdaTime           *gda_value_get_time (const GValue *value);
+const GdaTime                    *gda_value_get_time (const GValue *value);
 void                              gda_value_set_time (GValue *value, const GdaTime *val);
-const GdaTimestamp      *gda_value_get_timestamp (const GValue *value);
+const GdaTimestamp               *gda_value_get_timestamp (const GValue *value);
 void                              gda_value_set_timestamp (GValue *value, const GdaTimestamp *val);
 
 
diff --git a/libgda/libgda.symbols b/libgda/libgda.symbols
index 93f0b24..90cd010 100644
--- a/libgda/libgda.symbols
+++ b/libgda/libgda.symbols
@@ -32,10 +32,18 @@
        gda_batch_serialize
        gda_binary_copy
        gda_binary_free
+       gda_binary_new
+       gda_binary_get_data
+       gda_binary_get_size
        gda_binary_get_type
+       gda_binary_reset_data
+       gda_binary_set_data
        gda_binary_to_string
        gda_blob_copy
        gda_blob_free
+       gda_blob_new
+       gda_blob_get_binary
+       gda_blob_get_op
        gda_blob_get_type
        gda_blob_op_get_length
        gda_blob_op_get_type
diff --git a/libgda/sqlite/virtual/gda-vprovider-data-model.c 
b/libgda/sqlite/virtual/gda-vprovider-data-model.c
index ad448f6..fee377a 100644
--- a/libgda/sqlite/virtual/gda-vprovider-data-model.c
+++ b/libgda/sqlite/virtual/gda-vprovider-data-model.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2007 - 2016 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2009 Bas Driessen <bas driessen xobas com>
  * Copyright (C) 2010 David King <davidk openismus com>
  *
@@ -1050,7 +1050,7 @@ virtualColumn (sqlite3_vtab_cursor *cur, sqlite3_context *ctx, int i)
                                                    SQLITE_TRANSIENT);
        }
        else if (G_VALUE_TYPE (value) == GDA_TYPE_BINARY) {
-               const GdaBinary *bin;
+               GdaBinary *bin;
                bin = gda_value_get_binary (value);
                SQLITE3_CALL (sqlite3_result_blob) (ctx, gda_binary_get_data (bin), gda_binary_get_size 
(bin), SQLITE_TRANSIENT);
        }
diff --git a/providers/firebird/gda-firebird-blob-op.c b/providers/firebird/gda-firebird-blob-op.c
index be2eeeb..1692a2a 100644
--- a/providers/firebird/gda-firebird-blob-op.c
+++ b/providers/firebird/gda-firebird-blob-op.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2007 - 2016 Vivien Malerba <malerba gnome-db org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -154,7 +154,6 @@ static glong
 gda_firebird_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size)
 {
        GdaFirebirdBlobOp *pgop;
-       GdaBinary *bin;
 
        g_return_val_if_fail (GDA_IS_FIREBIRD_BLOB_OP (op), -1);
        pgop = GDA_FIREBIRD_BLOB_OP (op);
@@ -164,16 +163,10 @@ gda_firebird_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong siz
                return -1;
        g_return_val_if_fail (blob, -1);
 
-       bin = (GdaBinary *) blob;
-       if (bin->data) 
-               g_free (bin->data);
-       bin->data = g_new0 (guchar, size);
-       bin->binary_length = 0;
-
        /* fetch blob data using C API into bin->data, and set bin->binary_length */
        TO_IMPLEMENT;
 
-       return bin->binary_length;
+       return -1;
 }
 
 /*
@@ -183,7 +176,6 @@ static glong
 gda_firebird_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
 {
        GdaFirebirdBlobOp *pgop;
-       GdaBinary *bin;
 
        g_return_val_if_fail (GDA_IS_FIREBIRD_BLOB_OP (op), -1);
        pgop = GDA_FIREBIRD_BLOB_OP (op);
@@ -192,7 +184,6 @@ gda_firebird_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
        g_return_val_if_fail (blob, -1);
 
        /* write blob using bin->data and bin->binary_length */
-       bin = (GdaBinary *) blob;
        TO_IMPLEMENT;
 
        return -1;
diff --git a/providers/jdbc/GdaInputStream.c b/providers/jdbc/GdaInputStream.c
index 10beb57..0fac9c6 100644
--- a/providers/jdbc/GdaInputStream.c
+++ b/providers/jdbc/GdaInputStream.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 - 2013 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2008 - 2016 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2010 David King <davidk openismus com>
  *
  * This library is free software; you can redistribute it and/or
@@ -53,10 +53,12 @@ JNICALL Java_GdaInputStream_readData (JNIEnv *jenv, G_GNUC_UNUSED jobject obj,
        jint *data;
        GdaBlob *nblob = NULL;
        gint real_size;
-       if (blob->op) {
-               nblob = g_new0 (GdaBlob, 1);
-               gda_blob_set_op (nblob, blob->op);
-               real_size =  gda_blob_op_read (nblob->op, nblob, offset, size);
+       GdaBlobOp *op;
+       op = gda_blob_get_op (blob);
+       if (op) {
+               nblob = gda_blob_new ();
+               gda_blob_set_op (nblob, op);
+               real_size =  gda_blob_op_read (op, nblob, offset, size);
                if (real_size < 0) {
                        /* throw an exception */
                        jclass cls;
@@ -68,15 +70,15 @@ JNICALL Java_GdaInputStream_readData (JNIEnv *jenv, G_GNUC_UNUSED jobject obj,
                        (*jenv)->ThrowNew (jenv, cls, _("Can't read BLOB"));
                        return NULL;
                }
-               raw_data = ((GdaBinary*) nblob)->data;
+               raw_data = gda_binary_get_data ((GdaBinary*) nblob);
        }
        else {
                GdaBinary *bin = (GdaBinary *) blob;
-               if (offset + size > bin->binary_length)
-                       real_size = bin->binary_length - offset;
+               if (offset + size > gda_binary_get_size (bin))
+                       real_size = gda_binary_get_size (bin) - offset;
                else
                        real_size = size;
-               raw_data = bin->data + offset;
+               raw_data = gda_binary_get_data (bin) + offset;
        }
 
        /* convert bin->data to a jintArray */
@@ -126,10 +128,12 @@ Java_GdaInputStream_readByteData (JNIEnv *jenv, G_GNUC_UNUSED jobject obj,
        guchar *raw_data;
        GdaBlob *nblob = NULL;
        gint real_size;
-       if (blob->op) {
-               nblob = g_new0 (GdaBlob, 1);
-               gda_blob_set_op (nblob, blob->op);
-               real_size =  gda_blob_op_read (nblob->op, nblob, offset, size);
+       GdaBlobOp *op;
+       op = gda_blob_get_op (blob);
+       if (op) {
+               nblob = gda_blob_new ();
+               gda_blob_set_op (nblob, op);
+               real_size =  gda_blob_op_read (op, nblob, offset, size);
                if (real_size < 0) {
                        /* throw an exception */
                        jclass cls;
@@ -141,15 +145,15 @@ Java_GdaInputStream_readByteData (JNIEnv *jenv, G_GNUC_UNUSED jobject obj,
                        (*jenv)->ThrowNew (jenv, cls, _("Can't read BLOB"));
                        return NULL;
                }
-               raw_data = ((GdaBinary*) nblob)->data;
+               raw_data = gda_binary_get_data ((GdaBinary*) nblob);
        }
        else {
                GdaBinary *bin = (GdaBinary *) blob;
-               if (offset + size > bin->binary_length)
-                       real_size = bin->binary_length - offset;
+               if (offset + size > gda_binary_get_size (bin))
+                       real_size = gda_binary_get_size (bin) - offset;
                else
                        real_size = size;
-               raw_data = bin->data + offset;
+               raw_data = gda_binary_get_data (bin) + offset;
        }
 
        /* convert bin->data to a jintArray */
diff --git a/providers/jdbc/GdaJValue.c b/providers/jdbc/GdaJValue.c
index fef4a0b..cb06b26 100644
--- a/providers/jdbc/GdaJValue.c
+++ b/providers/jdbc/GdaJValue.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 - 2013 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2008 - 2016 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2010 David King <davidk openismus com>
  *
  * This library is free software; you can redistribute it and/or
@@ -317,21 +317,22 @@ JNICALL Java_GdaJValue_setCBinary (JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlon
        GValue *value;
        
        len = (*jenv)->GetArrayLength (jenv, bytes);
-       
-       bin = g_new0 (GdaBinary, 1);
-       bin->binary_length = len;
-       bin->data = g_new (guchar, len);
-       (*jenv)->GetByteArrayRegion(jenv, bytes, 0, len, (jbyte *) bin->data);
+
+       guchar *data;
+       data = g_new (guchar, len);
+       (*jenv)->GetByteArrayRegion(jenv, bytes, 0, len, (jbyte *) data);
 
        value = gda_row_get_value (GDA_ROW (jni_jlong_to_cpointer (c_pointer)), col);
+       bin = gda_binary_new ();
+       gda_binary_take_data (bin, data, len);
        gda_value_reset_with_type (value, GDA_TYPE_BINARY);
-       g_value_take_boxed (value, bin);
+       gda_value_take_binary (value, bin);
 }
 
 JNIEXPORT jbyteArray
 JNICALL Java_GdaJValue_getCBinary (JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlong c_pointer)
 {
-       const GdaBinary *bin;
+       GdaBinary *bin;
        jbyteArray jbytes;
 
        bin = g_value_get_boxed ((GValue *) jni_jlong_to_cpointer (c_pointer));
@@ -346,11 +347,11 @@ JNICALL Java_GdaJValue_getCBinary (JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlon
                return NULL;
        }
 
-       jbytes = (*jenv)->NewByteArray (jenv, bin->binary_length);
+       jbytes = (*jenv)->NewByteArray (jenv, gda_binary_get_size (bin));
        if ((*jenv)->ExceptionCheck (jenv))
                return NULL;
 
-       (*jenv)->SetByteArrayRegion (jenv, jbytes, 0, bin->binary_length, (jbyte*) bin->data);
+       (*jenv)->SetByteArrayRegion (jenv, jbytes, 0, gda_binary_get_size (bin), (jbyte*) gda_binary_get_data 
(bin));
        if ((*jenv)->ExceptionCheck (jenv))
                return NULL;
 
@@ -362,22 +363,25 @@ JNICALL Java_GdaJValue_setCBlob (JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlong
                                 jlong cnc_c_pointer, jobject blobop)
 {
        GdaBlob *blob;
+       GdaBlobOp *op;
        GValue *value;
 
-       blob = g_new0 (GdaBlob, 1);
-       blob->op = gda_jdbc_blob_op_new_with_jblob (GDA_CONNECTION (jni_jlong_to_cpointer (cnc_c_pointer)), 
jenv, blobop);
+       blob = gda_blob_new ();
+       op = gda_jdbc_blob_op_new_with_jblob (GDA_CONNECTION (jni_jlong_to_cpointer (cnc_c_pointer)), jenv, 
blobop);
+       gda_blob_set_op (blob, op);
+       g_object_unref (op);
 
        value = gda_row_get_value (GDA_ROW (jni_jlong_to_cpointer (c_pointer)), col);
        gda_value_reset_with_type (value, GDA_TYPE_BLOB);
-       g_value_take_boxed (value, blob);
+       gda_value_take_blob (value, blob);
 }
 
 JNIEXPORT jobject
 JNICALL Java_GdaJValue_getCBlob (JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlong c_pointer)
 {
-       const GdaBlob *blob;
+       GdaBlob *blob;
 
-       blob = g_value_get_boxed ((GValue *) jni_jlong_to_cpointer (c_pointer));
+       blob = gda_value_get_blob ((GValue *) jni_jlong_to_cpointer (c_pointer));
        if (!blob) {
                jclass cls;
                cls = (*jenv)->FindClass (jenv, "java/lang/IllegalArgumentException");
@@ -390,14 +394,16 @@ JNICALL Java_GdaJValue_getCBlob (JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlong
        }
 
        /* create a GdaInputStream */
-       if (blob->op) {
+       GdaBlobOp *op;
+       op = gda_blob_get_op (blob);
+       if (op) {
                jobject retobj;
                jmethodID mid;
                mid = (*jenv)->GetMethodID (jenv, GdaInputStream__class, "<init>", "(JJ)V");
                if ((*jenv)->ExceptionCheck (jenv))
                        return NULL;
 
-               glong size = gda_blob_op_get_length (blob->op);
+               glong size = gda_blob_op_get_length (op);
                if (size < 0) {
                        /* throw an exception */
                        jclass cls;
@@ -425,11 +431,11 @@ JNICALL Java_GdaJValue_getCBlob (JNIEnv *jenv, G_GNUC_UNUSED jobject obj, jlong
                if ((*jenv)->ExceptionCheck (jenv))
                        return NULL;
 
-               jbytes = (*jenv)->NewByteArray (jenv, bin->binary_length);
+               jbytes = (*jenv)->NewByteArray (jenv, gda_binary_get_size (bin));
                if ((*jenv)->ExceptionCheck (jenv))
                        return NULL;
                
-               (*jenv)->SetByteArrayRegion (jenv, jbytes, 0, bin->binary_length, (jbyte *) bin->data);
+               (*jenv)->SetByteArrayRegion (jenv, jbytes, 0, gda_binary_get_size (bin), (jbyte *) 
gda_binary_get_data (bin));
                if ((*jenv)->ExceptionCheck (jenv))
                        return NULL;
                
diff --git a/providers/jdbc/gda-jdbc-blob-op.c b/providers/jdbc/gda-jdbc-blob-op.c
index dfdf501..54f1735 100644
--- a/providers/jdbc/gda-jdbc-blob-op.c
+++ b/providers/jdbc/gda-jdbc-blob-op.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2008 - 2016 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2010 David King <davidk openismus com>
  *
  * This library is free software; you can redistribute it and/or
@@ -216,18 +216,18 @@ gda_jdbc_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size)
        }
 
        /* copy data */
-       bin = (GdaBinary *) blob;
-       if (bin->data) 
-               g_free (bin->data);
+       bin = gda_blob_get_binary (blob);
        bytes = (jbyteArray) gda_value_get_jni_object (jexec_res);
-       bin->binary_length = (*jenv)->GetArrayLength (jenv, bytes);
-       bin->data = g_new (guchar, bin->binary_length);
-       (*jenv)->GetByteArrayRegion(jenv, bytes, 0, bin->binary_length, (jbyte *) bin->data);
-
+       guchar *data;
+       glong length;
+       length = (*jenv)->GetArrayLength (jenv, bytes);
+       data = g_new (guchar, length);
+       (*jenv)->GetByteArrayRegion(jenv, bytes, 0, length, (jbyte *) data);
+       gda_binary_take_data (bin, data, length);
        _gda_jdbc_release_jenv (jni_detach);
        gda_value_free (jexec_res);
 
-       return bin->binary_length;
+       return length;
 }
 
 /*
@@ -258,19 +258,21 @@ gda_jdbc_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
        if (!jenv)
                return -1;
 
-       if (blob->op && (blob->op != op)) {
+       GdaBlobOp *blob_op;
+       blob_op = gda_blob_get_op (blob);
+       if (blob_op && (blob_op != op)) {
                /* use data through blob->op */
                #define buf_size 16384
                gint nread = 0;
                GdaBlob *tmpblob;
 
                nbwritten = 0;
-               tmpblob = g_new0 (GdaBlob, 1);
-               gda_blob_set_op (tmpblob, blob->op);
+               tmpblob = gda_blob_new ();
+               gda_blob_set_op (tmpblob, blob_op);
 
-               for (nread = gda_blob_op_read (tmpblob->op, tmpblob, 0, buf_size);
+               for (nread = gda_blob_op_read (blob_op, tmpblob, 0, buf_size);
                     nread > 0;
-                    nread = gda_blob_op_read (tmpblob->op, tmpblob, nbwritten, buf_size)) {
+                    nread = gda_blob_op_read (blob_op, tmpblob, nbwritten, buf_size)) {
                        GdaBinary *bin = (GdaBinary *) tmpblob;
                        glong tmp_written;
 
@@ -282,7 +284,7 @@ gda_jdbc_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
                                return -1;
                        }
 
-                       (*jenv)->SetByteArrayRegion (jenv, bytes, 0, nread, (jbyte*) bin->data);
+                       (*jenv)->SetByteArrayRegion (jenv, bytes, 0, nread, (jbyte*) gda_binary_get_data 
(bin));
                        if (jni_wrapper_handle_exception (jenv, &error_code, &sql_state, &error)) {
                                _gda_jdbc_make_error (bop->priv->cnc, error_code, sql_state, error);
                                (*jenv)->DeleteLocalRef (jenv, bytes);
@@ -318,14 +320,14 @@ gda_jdbc_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
        else {
                /* prepare data to be written using bin->data and bin->binary_length */
                bin = (GdaBinary *) blob;
-               bytes = (*jenv)->NewByteArray (jenv, bin->binary_length);
+               bytes = (*jenv)->NewByteArray (jenv, gda_binary_get_size (bin));
                if (jni_wrapper_handle_exception (jenv, &error_code, &sql_state, &error)) {
                        _gda_jdbc_make_error (bop->priv->cnc, error_code, sql_state, error);
                        _gda_jdbc_release_jenv (jni_detach);
                        return -1;
                }
                
-               (*jenv)->SetByteArrayRegion (jenv, bytes, 0, bin->binary_length, (jbyte*) bin->data);
+               (*jenv)->SetByteArrayRegion (jenv, bytes, 0, gda_binary_get_size (bin), (jbyte*) 
gda_binary_get_data (bin));
                if (jni_wrapper_handle_exception (jenv, &error_code, &sql_state, &error)) {
                        _gda_jdbc_make_error (bop->priv->cnc, error_code, sql_state, error);
                        (*jenv)->DeleteLocalRef (jenv, bytes);
diff --git a/providers/ldap/gda-ldap-util.c b/providers/ldap/gda-ldap-util.c
index 78b3db2..75087fa 100644
--- a/providers/ldap/gda-ldap-util.c
+++ b/providers/ldap/gda-ldap-util.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2011 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2011 - 2016 Vivien Malerba <malerba gnome-db org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -1016,15 +1016,10 @@ gda_ldap_attr_value_to_g_value (LdapConnectionData *cdata, GType type, BerValue
                }
        }
        else if (type == GDA_TYPE_BINARY) {
-               GdaBinary *bin;
-               bin = g_new (GdaBinary, 1);
-               bin->data = g_new (guchar, bv->bv_len);
-
-               bin->binary_length = bv->bv_len;
-               memcpy (bin->data, bv->bv_val,
-                       sizeof (gchar) * bin->binary_length);
-               value = gda_value_new (GDA_TYPE_BINARY);
-               gda_value_take_binary (value, bin);
+               guchar *data;
+               data = g_new (guchar, bv->bv_len);
+               memcpy (data, bv->bv_val, sizeof (guchar) * bv->bv_len);
+               value = gda_value_new_binary (data, bv->bv_len);
        }
        else
                value = gda_value_new_from_string (bv->bv_val, type);
diff --git a/providers/mdb/gda-mdb-provider.c b/providers/mdb/gda-mdb-provider.c
index a6b7389..a67c11c 100644
--- a/providers/mdb/gda-mdb-provider.c
+++ b/providers/mdb/gda-mdb-provider.c
@@ -5,7 +5,7 @@
  * Copyright (C) 2003 Gonzalo Paniagua Javier <gonzalo gnome-db org>
  * Copyright (C) 2004 Julio M. Merino Vidal <jmmv menta net>
  * Copyright (C) 2004 J�rg Billeter <j bitron ch>
- * Copyright (C) 2005 - 2015 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2005 - 2016 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2005 �lvaro Pe�a <alvaropg telefonica net>
  * Copyright (C) 2006 - 2007 Murray Cumming <murrayc murrayc com>
  * Copyright (C) 2007 yselkowitz <yselkowitz users sourceforge net>
@@ -518,17 +518,16 @@ table_create_model_func (LocalSpec *spec)
                for (c = 0; c < mdb_table->num_cols; c++) {
                        mdb_col = g_ptr_array_index (mdb_table->columns, c);
                        if (mdb_col->col_type == MDB_OLE) {
-                               GdaBinary bin;
-                               
-                               bin.binary_length = mdb_ole_read (spec->cdata->mdb, mdb_col, bound_values[c], 
MDB_BIND_SIZE);
-                               bin.data = (guchar*) bound_values[c];
-                               gda_value_set_binary ((tmpval = gda_value_new (coltypes [c])), &bin);
-                               
+                               tmpval = gda_value_new_binary ((guchar*) bound_values[c],
+                                                              mdb_ole_read (spec->cdata->mdb, mdb_col, 
bound_values[c],
+                                                                            MDB_BIND_SIZE));
 #ifdef DUMP_BINARY
                                {
                                        static int index = 0;
                                        gchar *file = g_strdup_printf ("OLE_%d.bin", index++);
-                                       g_file_set_contents (file, bin.data, bin.binary_length, NULL);
+                                       GdaBinary *bin;
+                                       bin = gda_value_get_binary (tmpval);
+                                       g_file_set_contents (file, gda_binary_get_data (bin), 
gda_binary_get_size (bin), NULL);
                                        g_free (file);
                                }
 #endif
diff --git a/providers/mysql/gda-mysql-blob-op.c b/providers/mysql/gda-mysql-blob-op.c
index 45f7d85..a772052 100644
--- a/providers/mysql/gda-mysql-blob-op.c
+++ b/providers/mysql/gda-mysql-blob-op.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2008 - 2016 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2011 - 2014 Murray Cumming <murrayc murrayc com>
  *
  * This library is free software; you can redistribute it and/or
@@ -154,7 +154,6 @@ gda_mysql_blob_op_read (GdaBlobOp  *op,
                        glong       size)
 {
        GdaMysqlBlobOp *pgop;
-       GdaBinary *bin;
 
        g_return_val_if_fail (GDA_IS_MYSQL_BLOB_OP (op), -1);
        pgop = GDA_MYSQL_BLOB_OP (op);
@@ -164,16 +163,10 @@ gda_mysql_blob_op_read (GdaBlobOp  *op,
                return -1;
        g_return_val_if_fail (blob, -1);
 
-       bin = (GdaBinary *) blob;
-       if (bin->data) 
-               g_free (bin->data);
-       bin->data = g_new0 (guchar, size);
-       bin->binary_length = 0;
-
        /* fetch blob data using C API into bin->data, and set bin->binary_length */
        TO_IMPLEMENT;
 
-       return bin->binary_length;
+       return -1;
 }
 
 /*
diff --git a/providers/mysql/gda-mysql-provider.c b/providers/mysql/gda-mysql-provider.c
index aa7fcd5..eec5671 100644
--- a/providers/mysql/gda-mysql-provider.c
+++ b/providers/mysql/gda-mysql-provider.c
@@ -12,7 +12,7 @@
  * Copyright (C) 2004 J�rg Billeter <j bitron ch>
  * Copyright (C) 2004 Szalai Ferenc <szferi einstein ki iif hu>
  * Copyright (C) 2005 - 2009 Bas Driessen <bas driessen xobas com>
- * Copyright (C) 2005 - 2015 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2005 - 2016 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2005 �lvaro Pe�a <alvaropg telefonica net>
  * Copyright (C) 2007 Armin Burgmeier <armin openismus com>
  * Copyright (C) 2007 - 2014 Murray Cumming <murrayc murrayc com>
@@ -2552,7 +2552,7 @@ gda_mysql_provider_statement_execute (GdaServerProvider               *provider,
                        mysql_bind_param[i].length = NULL;
                }
                else if (G_VALUE_TYPE (value) == GDA_TYPE_BLOB) {
-                       const GdaBinary *bin = NULL;
+                       GdaBinary *bin = NULL;
                        GdaBlob *blob = (GdaBlob*) gda_value_get_blob (value);
 
                        bin = ((GdaBinary*) blob);
@@ -2563,16 +2563,18 @@ gda_mysql_provider_statement_execute (GdaServerProvider               *provider,
                        else {
                                gchar *str = NULL;
                                glong blob_len;
-                               if (blob->op) {
-                                       blob_len = gda_blob_op_get_length (blob->op);
-                                       if ((blob_len != bin->binary_length) &&
-                                           ! gda_blob_op_read_all (blob->op, blob)) {
+                               GdaBlobOp *op;
+                               op = gda_blob_get_op (blob);
+                               if (op) {
+                                       blob_len = gda_blob_op_get_length (op);
+                                       if ((blob_len != gda_binary_get_size (bin)) &&
+                                           ! gda_blob_op_read_all (op, blob)) {
                                                /* force reading the complete BLOB into memory */
                                                str = _("Can't read whole BLOB into memory");
                                        }
                                }
                                else
-                                       blob_len = bin->binary_length;
+                                       blob_len = gda_binary_get_size (bin);
                                if (blob_len < 0)
                                        str = _("Can't get BLOB's length");
                                else if (blob_len >= G_MAXINT)
@@ -2587,24 +2589,24 @@ gda_mysql_provider_statement_execute (GdaServerProvider               *provider,
                                }
                                
                                else {
-                                       mysql_bind_param[i].buffer_type= MYSQL_TYPE_BLOB;
-                                       mysql_bind_param[i].buffer= (char *) bin->data;
-                                       mysql_bind_param[i].buffer_length = bin->binary_length;
+                                       mysql_bind_param[i].buffer_type = MYSQL_TYPE_BLOB;
+                                       mysql_bind_param[i].buffer = (char *) gda_binary_get_data (bin);
+                                       mysql_bind_param[i].buffer_length = gda_binary_get_size (bin);
                                        mysql_bind_param[i].length = NULL;
                                }
                        }
                }
                else if (G_VALUE_TYPE (value) == GDA_TYPE_BINARY) {
-                       const GdaBinary *bin;
-                       bin = gda_value_get_binary (value);
+                       GdaBinary *bin;
+                       bin = gda_value_get_binary ((GValue*) value);
                        if (!bin) {
                                mysql_bind_param[i].buffer_type = MYSQL_TYPE_NULL;
                                mysql_bind_param[i].is_null = (my_bool*)1;
                        }
                        else {
-                               mysql_bind_param[i].buffer_type= MYSQL_TYPE_BLOB;
-                               mysql_bind_param[i].buffer= (char *) bin->data;
-                               mysql_bind_param[i].buffer_length = bin->binary_length;
+                               mysql_bind_param[i].buffer_type = MYSQL_TYPE_BLOB;
+                               mysql_bind_param[i].buffer = (char *) gda_binary_get_data (bin);
+                               mysql_bind_param[i].buffer_length = gda_binary_get_size (bin);
                                mysql_bind_param[i].length = NULL;
                        }
                }
diff --git a/providers/mysql/gda-mysql-recordset.c b/providers/mysql/gda-mysql-recordset.c
index 403a048..2e1aae4 100644
--- a/providers/mysql/gda-mysql-recordset.c
+++ b/providers/mysql/gda-mysql-recordset.c
@@ -7,7 +7,7 @@
  * Copyright (C) 2003 Chris Silles <csilles src gnome org>
  * Copyright (C) 2003 Laurent Sansonetti <lrz gnome org>
  * Copyright (C) 2003 Paisa Seeluangsawat <paisa users sf net>
- * Copyright (C) 2004 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2004 - 2016 Vivien Malerba <malerba gnome-db org>
  * Copyright (C) 2005 Alan Knowles <alan akbkhome com>
  * Copyright (C) 2005 - 2009 Bas Driessen <bas driessen xobas com>
  * Copyright (C) 2005 Mike Fisk <mfisk woozle org>
@@ -949,18 +949,19 @@ new_row_from_mysql_stmt (GdaMysqlRecordset *imodel, G_GNUC_UNUSED gint rownum, G
                        if (type == G_TYPE_STRING)
                                g_value_set_string (value, bvalue);
                        else if (type == GDA_TYPE_BINARY) {
-                               GdaBinary binary = {
-                                       .data = (guchar*) bvalue,
-                                       .binary_length = length
-                               };
-                               gda_value_set_binary (value, &binary);
+                               GdaBinary *bin;
+                               bin = gda_binary_new ();
+                               gda_binary_set_data (bin, (guchar*) bvalue, length);
+                               gda_value_take_binary (value, bin);
                        }
                        else if (type == GDA_TYPE_BLOB) {
                                /* we don't use GdaMysqlBlobOp because it looks like the MySQL
                                 * API does not support BLOBs accessed in a random way,
                                 * so we return the whole BLOB at once */
-                               GdaBlob blob = { {(guchar*) bvalue, length}, NULL };
-                               gda_value_set_blob (value, &blob);
+                               GdaBlob *blob = gda_blob_new ();
+                               GdaBinary *bin = gda_blob_get_binary (blob);
+                               gda_binary_set_data (bin, (guchar*) bvalue, length);
+                               gda_value_take_blob (value, blob);
                        }
                        else if (type == GDA_TYPE_NUMERIC) {
                                if (length > 0) {
diff --git a/providers/oracle/gda-oracle-blob-op.c b/providers/oracle/gda-oracle-blob-op.c
index daf328a..302d9c3 100644
--- a/providers/oracle/gda-oracle-blob-op.c
+++ b/providers/oracle/gda-oracle-blob-op.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2007 - 2016 Vivien Malerba <malerba gnome-db org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -150,7 +150,6 @@ static glong
 gda_oracle_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size)
 {
        GdaOracleBlobOp *bop;
-       GdaBinary *bin;
 
        g_return_val_if_fail (GDA_IS_ORACLE_BLOB_OP (op), -1);
        bop = GDA_ORACLE_BLOB_OP (op);
@@ -160,16 +159,10 @@ gda_oracle_blob_op_read (GdaBlobOp *op, GdaBlob *blob, glong offset, glong size)
                return -1;
        g_return_val_if_fail (blob, -1);
 
-       bin = (GdaBinary *) blob;
-       if (bin->data) 
-               g_free (bin->data);
-       bin->data = g_new0 (guchar, size);
-       bin->binary_length = 0;
-
        /* fetch blob data using C API into bin->data, and set bin->binary_length */
        TO_IMPLEMENT;
 
-       return bin->binary_length;
+       return -1;
 }
 
 /*
@@ -187,25 +180,27 @@ gda_oracle_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
        g_return_val_if_fail (GDA_IS_CONNECTION (bop->priv->cnc), -1);
        g_return_val_if_fail (blob, -1);
 
-       if (blob->op && (blob->op != op)) {
+       GdaBlobOp *blob_op;
+       blob_op = gda_blob_get_op (blob);
+       if (blob_op && (blob_op != op)) {
                /* use data through blob->op */
                #define buf_size 16384
                gint nread = 0;
-               GdaBlob *tmpblob = g_new0 (GdaBlob, 1);
-               gda_blob_set_op (tmpblob, blob->op);
+               GdaBlob *tmpblob = gda_blob_new ();
+               gda_blob_set_op (tmpblob, blob_op);
 
                nbwritten = 0;
 
-               for (nread = gda_blob_op_read (tmpblob->op, tmpblob, nbwritten, buf_size);
+               for (nread = gda_blob_op_read (blob_op, tmpblob, nbwritten, buf_size);
                     nread > 0;
-                    nread = gda_blob_op_read (tmpblob->op, tmpblob, nbwritten, buf_size)) {
+                    nread = gda_blob_op_read (blob_op, tmpblob, nbwritten, buf_size)) {
                        glong tmp_written;
 
                        tmp_written = -1; TO_IMPLEMENT;
                        
                        if (tmp_written < 0) {
                                /* treat error */
-                               gda_blob_free ((gpointer) tmpblob);
+                               gda_blob_free (tmpblob);
                                return -1;
                        }
                        nbwritten += tmp_written;
@@ -213,7 +208,7 @@ gda_oracle_blob_op_write (GdaBlobOp *op, GdaBlob *blob, glong offset)
                                /* nothing more to read */
                                break;
                }
-               gda_blob_free ((gpointer) tmpblob);
+               gda_blob_free (tmpblob);
        }
        else {
                /* write blob using bin->data and bin->binary_length */
diff --git a/providers/oracle/gda-oracle-util.c b/providers/oracle/gda-oracle-util.c
index 813b785..213f01c 100644
--- a/providers/oracle/gda-oracle-util.c
+++ b/providers/oracle/gda-oracle-util.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2009 - 2014 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2009 - 2016 Vivien Malerba <malerba gnome-db org>
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
@@ -434,8 +434,8 @@ _gda_value_to_oracle_value (const GValue *value)
                bin = (GdaBinary *) gda_value_get_blob ((GValue *) value);
                if (bin) {
                        ora_value->sql_type = SQLT_LNG;
-                       ora_value->value = bin->data;
-                       ora_value->defined_size = bin->binary_length;
+                       ora_value->value = gda_binary_get_data (bin);
+                       ora_value->defined_size = gda_binary_get_size (bin);
                }
                else {
                        ora_value->sql_type = SQLT_CHR;
@@ -449,8 +449,8 @@ _gda_value_to_oracle_value (const GValue *value)
                bin = (GdaBinary *) gda_value_get_binary ((GValue *) value);
                if (bin) {
                        ora_value->sql_type = SQLT_LNG;
-                       ora_value->value = bin->data;
-                       ora_value->defined_size = bin->binary_length;
+                       ora_value->value = gda_binary_get_data (bin);
+                       ora_value->defined_size = gda_binary_get_size (bin);
                }
                else {
                        ora_value->sql_type = SQLT_CHR;
@@ -600,16 +600,15 @@ _gda_oracle_set_value (GValue *value,
        case GDA_STYPE_BINARY: {
                GdaBinary *bin;
 
-               bin = g_new0 (GdaBinary, 1);
-               if (ora_value->use_callback) {          
-                       bin->data = ora_value->value;
+               bin = gda_binary_new ();
+               if (ora_value->use_callback) {
+                       gda_binary_take_data (bin, ora_value->value, ora_value->rlen);
                        ora_value->value = NULL;
+                       ora_value->rlen = 0;
                }
                else {
-                       bin->data = g_new (guchar, ora_value->rlen);
-                       memcpy (bin->data, ora_value->value, ora_value->rlen);
+                       gda_binary_set_data (bin, ora_value->value, ora_value->rlen);
                }
-               bin->binary_length = ora_value->rlen;
                gda_value_take_binary (value, bin);
                break;
        }
@@ -643,7 +642,7 @@ _gda_oracle_set_value (GValue *value,
                        return;
                }
 
-               blob = g_new0 (GdaBlob, 1);
+               blob = gda_blob_new ();
                op = gda_oracle_blob_op_new (cnc, lobloc);
                gda_blob_set_op (blob, op);
                g_object_unref (op);
diff --git a/tools/browser/ldap-browser/entry-properties.c b/tools/browser/ldap-browser/entry-properties.c
index 393ad49..6cbb156 100644
--- a/tools/browser/ldap-browser/entry-properties.c
+++ b/tools/browser/ldap-browser/entry-properties.c
@@ -1,6 +1,6 @@
 /*
  * Copyright (C) 2011 Murray Cumming <murrayc murrayc com>
- * Copyright (C) 2011 - 2015 Vivien Malerba <malerba gnome-db org>
+ * Copyright (C) 2011 - 2016 Vivien Malerba <malerba gnome-db org>
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -232,14 +232,14 @@ data_save_cb (GtkWidget *mitem, EntryProperties *eprop)
                char *filename;
                GValue *binvalue;
                GError *lerror = NULL;
-               const GdaBinary *bin = NULL;
+               GdaBinary *bin = NULL;
 
                filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
                binvalue = g_object_get_data (G_OBJECT (mitem), "binvalue");
                if (binvalue)
                        bin = gda_value_get_binary (binvalue);
-               if (!bin || !g_file_set_contents (filename, (gchar*) bin->data,
-                                                 bin->binary_length, &lerror)) {
+               if (!bin || !g_file_set_contents (filename, (gchar*) gda_binary_get_data (bin),
+                                                 gda_binary_get_size (bin), &lerror)) {
                        ui_show_error ((GtkWindow*) gtk_widget_get_toplevel (GTK_WIDGET (eprop)),
                                            _("Could not save data: %s"),
                                            lerror && lerror->message ? lerror->message : _("No detail"));
@@ -487,15 +487,15 @@ data_to_pixbuf (const GValue *cvalue)
        GdkPixbuf *retpixbuf = NULL;
 
        if (G_VALUE_TYPE (cvalue) == GDA_TYPE_BINARY) {
-               const GdaBinary *bin;
+               GdaBinary *bin;
                GdkPixbufLoader *loader;
-
-               bin = gda_value_get_binary (cvalue);
-               if (!bin->data)
+               
+               bin = gda_value_get_binary ((GValue*) cvalue);
+               if (!gda_binary_get_data (bin))
                        goto out;
 
                loader = gdk_pixbuf_loader_new ();
-               if (gdk_pixbuf_loader_write (loader, bin->data, bin->binary_length, NULL)) {
+               if (gdk_pixbuf_loader_write (loader, gda_binary_get_data (bin), gda_binary_get_size (bin), 
NULL)) {
                        if (gdk_pixbuf_loader_close (loader, NULL)) {
                                retpixbuf = gdk_pixbuf_loader_get_pixbuf (loader);
                                g_object_ref (retpixbuf);



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