IdrisDoc: CFFI.Memory

CFFI.Memory

Machinery for interfacing with C.

(#) : Composite -> Nat -> CPtr -> CPtr

Get a pointer to a field in a composite value

Fixity
Left associative, precedence 10
data CPtr : Type
CPt : Ptr -> Int -> CPtr
alloc : Composite -> IO CPtr

Allocate enough memory to hold an instance of a C typr

calloc : Int -> Int -> IO Ptr

Import of calloc from the C standard library.

field : Composite -> Nat -> CPtr -> CPtr

Get a pointer to a field in a composite value

free : CPtr -> IO ()

Free memory allocated with alloc

malloc : Int -> IO Ptr

Import of malloc from the C standard library.

mfree : Ptr -> IO ()

Import of free from the C standard library.

peek : (t : CType) -> CPtr -> IO (translate t)

Read from memory

poke : (t : CType) -> CPtr -> translate t -> IO ()

Write to memory

toCPtr : Ptr -> CPtr
toPtr : CPtr -> Ptr
update : (t : CType) -> CPtr -> (translate t -> translate t) -> IO ()

Update memory with a function.

withAlloc : Composite -> (CPtr -> IO a) -> IO a

Perform an IO action with memory that is freed afterwards

(~~>) : Composite -> (CPtr -> IO ()) -> IO ()

Perform an IO action with memory that is freed afterwards

Fixity
Left associative, precedence 1