FFI and complex data structures
Andreas Raab
andreas.raab at gmx.de
Sun Apr 10 11:01:02 UTC 2005
Martin Kuball wrote:
> decodeStructure bitstream: (ExternalData fromHandle: aFrameBuffer
> type: ExternalType byte asPointerType).
>
> This triggers the error: Only external addresses can be stored.
> So Is this just impossible? Do I have to write a real plugin?
If aFrameBuffer is a ByteArray (as I suspect) this will fail since the
FFI will not allow you store addresses of objects living inside the
Squeak object memory. Those are *movable* and storing the address for
some C function call is meaningless - the Squeak garbage collector might
have long moved this object away from this address and you'd start to
overwrite random pieces of Squeak memory.
You need to create the byte array in external memory say:
pointer := ExternalAddress allocate: aFrameBuffer size.
decodeStructure bitstream: (ExternalData
fromHandle: pointer
type: ExternalType byte asPointerType).
Cheers,
- Andreas
More information about the Squeak-dev
mailing list
|