package ctypes

  1. Overview
  2. Docs
type (_, _) t

A fat pointer, which holds a reference to the reference type, the C memory location, and an OCaml object.

val make : managed:'m -> reftyp:'typ -> voidp -> ('m, 'typ) t

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
val coerce : ('m, _) t -> 'typ -> ('m, 'typ) t
val unsafe_raw_addr : (_, _) t -> voidp

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.

val add_bytes : ('m, 'typ) t -> int -> ('m, 'typ) t
val compare : (_, 'typ) t -> (_, 'typ) t -> int
val diff_bytes : (_, 'typ) t -> (_, 'typ) t -> int

Innovation. Community. Security.