Ctypes_ptr.Fat
A fat pointer, which holds a reference to the reference type, the C memory location, and an OCaml object.
make ?managed ~reftyp raw
builds a fat pointer from the reference type reftyp
, the C memory location raw
, and (optionally) an OCaml value, managed
. The managed
argument may be used to manage the lifetime of the C object; a typical use it to attach a finaliser to managed
which releases the memory associated with the C object whose address is stored in raw_ptr
.
val is_null : (_, _) t -> bool
val reftype : (_, 'typ) t -> 'typ
val managed : ('m, _) t -> 'm
val set_managed : ('m, _) t -> 'm -> unit
Return the raw pointer address. The function is unsafe in the sense that it dissociates the address from the value which manages the memory, which may trigger associated finalisers, invalidating the address.