A type representation for a function pointer type with explicit lifetime management.
This behaves like
t, except that null pointers appear in OCaml as
val free : t -> unit
Indicate that the
fptr is no longer needed.
free has been called any C calls to this
Dynamic_funptr.t are unsafe. Only call
free once the callback is no longer used from C.
Turn an OCaml closure into a function pointer that can be passed to C.
with_fun encapsulates both allocation and deallocation.
with_fun fn (fun fptr -> e) - Turn an OCaml closure into a function pointer and perform simple life cycle management.
with_fun fn (fun fptr -> e) will call
free fptr after
with_fun is not safe to use if the C function ptr
fptr may still be used after