Go to the first, previous, next, last section, table of contents.
A stable pointer is a name for a Haskell object which can be passed to
the external world. It is "stable" in the sense that the name does
not change when the Haskell garbage collector runs -- in contrast to
the address of the object which may well change.
The stable pointer type is parameterised by the type of the thing
which is named.
type StablePtr# a
A stable pointer is represented by an index into the (static)
`StablePointerTable'. The Haskell garbage collector treats the
`StablePointerTable' as a source of roots for GC.
The `makeStablePointer' function converts a value into a stable
pointer. It is part of the `IO' monad, because we want to be sure
we don't allocate one twice by accident, and then only free one of the
copies.
makeStablePointer# :: a -> State# RealWorld -> StateAndStablePtr# RealWorld a
freeStablePointer# :: StablePtr# a -> State# RealWorld -> State# RealWorld
deRefStablePointer# :: StablePtr# a -> State# RealWorld -> StateAndPtr RealWorld a
There is also a C procedure `FreeStablePtr' which frees a stable pointer.
Go to the first, previous, next, last section, table of contents.