Thanks a lot Jeremy! I went with the ptr_opt way, thought I'm a bit surprised it works:
> let foo_bar x = > let ret = allocate foo_opt (Some x) in > let r = foo_bar ret (Some x) in > (r, !@ret) Intuitively I thought `ret` could never be null, because calling `allocate` would be akin to calling malloc() + memset() in C. I also believed that if the C library would set `*ret = NULL`, this would cause a leak of the memory allocated in `allocate`. So I guess my understanding is incorrect :) In the actual code I used let ret = allocate foo_opt None in ... since there's no meaningful initial value to be set on `ret`. It seems to be working fine :) Thanks again, Andre
signature.asc
Description: OpenPGP digital signature
_______________________________________________ Ctypes mailing list [email protected] http://lists.ocaml.org/listinfo/ctypes
