Hello,

2010/4/22 Michael Wild <[email protected]>:
>> I don't understand this, does the function still alocate the instance,
>> or does it just initialize it?
>
> It does both, it just doesn't return the result in the return argument, but 
> in one of the parameters. I found an example with the same issue, but I don't 
> understand how Vala can be doing the right thing. Looking at zlib.vapi I see
>
> [CCode (cname = "z_stream", destroy_function = "deflateEnd")]
> public struct DeflateStream : Stream {
>    [CCode (cname = "deflateInit")]
>    public DeflateStream (int level = Level.DEFAULT_COMPRESSION);
>    // ...
> }
>
> but deflateInit has the following (sanitized) signature:
>
> int deflateInit(z_stream *strm, int level);
>
> How does Vala know that it must pick the first argument and not the return 
> value?
Because the function doesn't allocate the struct, only initializes it.
So it's used :

z_stream strm;
deflateInit(&strm, ...);

this way you have to declare your type as a struct (and not a class).

HTH,
Abderrahim
_______________________________________________
vala-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/vala-list

Reply via email to