[Haskell-cafe] FFI and modifying haskell memory

Joel Reymont joelr1 at gmail.com
Fri Oct 21 10:19:36 EDT 2005

Is there a particular reason why StablePtr cannot provide a "fixed"  
memory address? Then 4 bytes of memory won't need to be allocated so  
that C could write to them and C could just modify the Haskell variable.

On Oct 21, 2005, at 3:17 PM, Simon Marlow wrote:

> yes, something like
>    with $ \pculong ->
>      r <- uncompress_ buf pculong ...
>      size <- peek pculong
>> I thought StablePtr would give me the address of a Haskell value but
>> it gives me an offset into some table instead.
> That's right, the reason being that Haskell values move around when GC
> happens.


More information about the Haskell-Cafe mailing list