Re: [Vala] Copy function produces segmentation fault



On Wed, May 18, 2011 at 3:21 AM, Luca Bruno <lethalman88 gmail com> wrote:

On Tue, May 17, 2011 at 01:55:57PM -0600, Lewis Gunsch wrote:
Hi,

I have been writing a Vapi for the ZeroMQ library:
http://www.zeromq.org/. I
would eventually like it to be distributed with Vala itself, and would
propose myself as the maintainer.

See the vapi here:
https://github.com/lgunsch/zmq-vala/blob/master/libzmq.vapi

Would you add a link to http://live.gnome.org/Vala/ExternalBindings ?


Done. I added the link to the bottom of the list.


 > Although, I am having some trouble getting the MSG.Msg.copy() message
copy
function to work correctly. It produces a segmentation fault. I am unsure
how to go about fixing this issue. You can see the docs for the libraries
copy function below.

http://api.zeromq.org/2-1:zmq-msg-copy

Try with:
[CCode (instance_pos = 2)]
public int copy (out Msg dest);

Use as:
Msg copy;
int res = somemsg.copy (out copy);


After digging around, I found out that a message has to be initialized
before copying. Because it has to be initialized, I can't use the out
parameter, but it looks like the ref parameter would make sense here.

[CCode (instance_pos = 2)]
public int copy(ref Msg dest);

Used as:
Msg copy = MSG.Msg ();
int res =  msg.copy (ref copy);

~Lewis


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