<div class="gmail_quote"><div>Thanks for the reply, Mariano! I tried your advice but I ended up with some &quot;Could not coerce arguments&quot; errors and crashing the VM several times :P. </div><div>However, I tried something like this:</div>

<div><br></div><div>IplImage&gt;&gt;free</div><div>SqueakCV apiReleaseImage: handle asByteArrayPointer.<br></div><div><br></div><div><div>SqueakCV&gt;&gt;apiReleaseImage: doublePointer </div><div><span class="Apple-tab-span" style="white-space:pre">        </span>&lt;apicall: void &#39;cvReleaseImage&#39; (byte*) module: &#39;cxcore110.dll&#39;&gt;</div>

<div><span class="Apple-tab-span" style="white-space:pre">        </span>^ self externalCallFailed</div></div><div><br></div><div><br></div><div>It appears to be working. I don&#39;t know if this is the right way to do it, though. I don&#39;t know either if overriding #free is ok and it would not bring problems later...</div>

<div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><span class="Apple-style-span" style="font-family: Arial; font-size: 16px; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; "><pre style="font-family: monospace; margin-left: 3em; font-size: 90%; ">

&gt;<i> 2)      To finalize objects the OpenCV library defines some functions such
</i>&gt;<i> as cvReleaseImage, cvReleaseMat, etc. As far as I can tell, these functions
</i>&gt;<i> receive a pointer-to-pointer as argument. How can I declare such a method in
</i>&gt;<i> Squeak? Having one object, how can I get the pointer to that object? Should
</i>&gt;<i> I use the #getHandle method?
</i>&gt;<i>
</i>
In OpenDBX we have a functions like this for example:

    long odbx_init(odbx_t**, char*, char*, char*)

This is how I declare it:

apiInitialize: handle backend: backend host: host port: port
    &lt;cdecl: long &#39;odbx_init&#39; (ulong* char* char* char*) module: &#39;opendbx&#39;&gt;
    ^self externalCallFailed

Remember a pinter to a pointer is a long :)

And then in the code I do something like this:

handleArray := WordArray with: 0.
    err := OpenDBX current
                apiInitialize: handleArray
                backend: self backend
                host: aConnection settings host
                port: aConnection settings port.

Notice the WordArray.

I have no idea of 1) and 3) sorry.

I hope this helps. If this do help, perhaps we can put it in FFI wiki page.

Cheers,

Mariano</pre></span></blockquote></div><br>