help-smalltalk
[Top][All Lists]
Advanced

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

Re: [Help-smalltalk] c callouts and char**


From: Paolo Bonzini
Subject: Re: [Help-smalltalk] c callouts and char**
Date: Sun, 9 Jan 2011 18:14:39 +0100

On Sun, Jan 9, 2011 at 15:57, Thiago Silva <address@hidden> wrote:
> Hello,
>
> I was running through the docs and doing some experiments but couldn't
> find a way to convert an Array of Strings to char**.

A "CString new: 5" is an array of 5 strings (a pointer to 5 char*).
Something like

cstring at: 3 put: 'abc'

would fill the fourth pointer and automatically allocate memory for
the 'abc' string.

Note that CStrings can be a good source of memory leaks since you have
to free the elements as well.

> Somewhere I read
> that was possible to return an int** using "#(#ptr #{CInt})". I tried
> to pass #( 1 2 3) as parameter using this scheme but got "Attempt to
> pass an instance of Array as a void *".

No, Smaltalk objects are not automatically converted to instances from
the CObject hierarchy.

Paolo



reply via email to

[Prev in Thread] Current Thread [Next in Thread]