(no subject)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

(no subject)

Schwab,Wilhelm K
Andreas,

Thanks for code, but should this not be in the image, associated in some way with ExternalAddress and/or ByteArray?

Can I simply use a ByteArray to make a buffer that I pass to an external library?  My understanding is that it could be moved by the gc (ouch!!)  Am I wrong?  If there is a way to instantiate a byte array that won't move, great.  What about ExternalAddress>>finalize?

Bill



Andreas Raab andreas.raab at gmx.de
Mon Aug 23 20:33:04 UTC 2010

On 8/23/2010 12:46 PM, Schwab,Wilhelm K wrote:
> Are there any well-worn ways to move data into and out of external memory?

You mean like:

memcpyTo: destAddr from: srcAddr length: sz
        <cdecl: long 'memcpy' (void* void* ulong) module: 'libc.so'>
        ^self externalCallFailed

Reply | Threaded
Open this post in threaded view
|

Re: (no subject)

Bert Freudenberg

On 23.08.2010, at 23:16, Schwab,Wilhelm K wrote:

> Andreas,
>
> Thanks for code, but should this not be in the image, associated in some way with ExternalAddress and/or ByteArray?
>
> Can I simply use a ByteArray to make a buffer that I pass to an external library?  My understanding is that it could be moved by the gc (ouch!!)  Am I wrong?  If there is a way to instantiate a byte array that won't move, great.  

It won't move while you are calling that library. But it can move after return. So as long as the library does not retain a pointer to the buffer, this will work fine.

If the lib *does* retain the pointer, use ExternalAddress allocate: or gcallocate: to make the buffer, and memcpy to fill it quickly or retrieve the data.

- Bert -