Replies: 1 comment 1 reply
-
I think it's better to avoid |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Or more generally allow the user to create views types where the memory which is allocated on OCaml side is GC-ed, but the one which is passed to the C is not freed when it is not longer reachable.
Motivating example:
I'm trying to pass an OCaml callback to C which returns a string. After that the C code "takes ownership" of the returned string
and frees it after use.
Then when the
char ptr
holding a reference to string on OCaml side is garbage collected this functionocaml-ctypes/src/ctypes/managed_buffer_stubs.c
Line 19 in 96e1ac3
The result of this double-free is that the program crashes.
So, if that is possible, I want an
unmaged_string
where the finalizer for that custom block is null or does nothing.Beta Was this translation helpful? Give feedback.
All reactions