[FFI] Pointer arithmetic impossible on ByteArray?
andreas.raab at gmx.de
Sat May 20 00:30:41 UTC 2006
Not a chance. The "base address" of an object isn't constant; the object
will be moved by a GC and therefore you simply can't guarantee that "foo
baseAddress" is a meaningful value for any period of time other than in
the primitive call itself (even the return from the primitive could
cause a process switch, which could cause GC somewhere, which could move
the object, which invalidates the base address).
nicolas cellier wrote:
> Now playing with FFI, i really appreciate to be able to handle memory in a
> Smalltalk space, with a ByteArray.
> Unfotunately, one little thing lack on ByteArray: pointer arithmetic.
> I'd like to pass an address kind of (aByteArray baseAdress + 4) to a FFI CALL
> for example...
> I can do that right now with external heap (ExternalAddress new fromInteger:
> anAddress asInteger + 4), but not with Smalltalk-space.
> Maybe an IndirectByteArray could be added to the FFI plugin?
> This would be really cool.
More information about the Squeak-dev