On Sun, Jun 26, 2011 at 13:18, Iñigo Serna <[email protected]> wrote:

> if I include a line like:
>
> uint8[]? data = (uint8[]) stmt.column_blob(3);
>
> it's translated as next C code:
>
> _tmp11_ = (_tmp10_ = (guint8*) _tmp9_, (_tmp10_ == NULL) ? ((gpointer)
> _tmp10_) : _vala_array_dup3 (_tmp10_, -1));
>

I had this problem a lot of times before I realized that Vala arrays must
have a length, but this length is not always retrieved by the API, so Vala
has no idea of the size of the array returned from Sqlite. The -1 ilustrated
at the C code shows this, because Vala thinks this array has -1 items.
You can use stmt.column_bytes to retrieve the number of items in the array
(at this case, the number of bytes) and assign it to the array length such
as:

data.length = stmt.column_bytes(3);

So now Vala knows the size of the array and you can use it anyway you want
to.

*Alexandre Rosenfeld*
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to