Foreign.Ptr
Contents
Description
The module Foreign.Ptr provides typed pointers to foreign entities. We distinguish two kinds of pointers: pointers to data and pointers to functions. It is understood that these two kinds of pointers may be represented differently as they may be references to data and text segments, respectively.
- Ptr
- nullPtr
- castPtr
- plusPtr
- alignPtr
- minusPtr
- FunPtr
- nullFunPtr
- castFunPtr
- castFunPtrToPtr
- castPtrToFunPtr
- freeHaskellFunPtr :: FunPtr a -> IO ()
- data IntPtr
- ptrToIntPtr :: Ptr a -> IntPtr
- intPtrToPtr :: IntPtr -> Ptr a
- data WordPtr
- ptrToWordPtr :: Ptr a -> WordPtr
- wordPtrToPtr :: WordPtr -> Ptr a
Data pointers
Function pointers
freeHaskellFunPtr :: FunPtr a -> IO ()Source
Release the storage associated with the given FunPtr, which
must have been obtained from a wrapper stub. This should be called
whenever the return value from a foreign import wrapper function is
no longer required; otherwise, the storage it uses will leak.
Integral types with lossless conversion to and from pointers
A signed integral type that can be losslessly converted to and from
Ptr. This type is also compatible with the C99 type intptr_t, and
can be marshalled to and from that type safely.
ptrToIntPtr :: Ptr a -> IntPtrSource
casts a Ptr to an IntPtr
intPtrToPtr :: IntPtr -> Ptr aSource
casts an IntPtr to a Ptr
An unsigned integral type that can be losslessly converted to and from
Ptr. This type is also compatible with the C99 type uintptr_t, and
can be marshalled to and from that type safely.
ptrToWordPtr :: Ptr a -> WordPtrSource
casts a Ptr to a WordPtr
wordPtrToPtr :: WordPtr -> Ptr aSource
casts a WordPtr to a Ptr