-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
caml_output_value_to_malloc: really use malloc #12566
Conversation
Change looks good to me: I assume it was changed by mistake in 02a8b99 when grepping for malloc occurrences? |
(Changes entry needs update, will merge afterward.) |
External users (unison, hhvm, pyre-check) assume that the memory they get from `caml_output_value_to_malloc` can be freed with `free`. The function was changed to use caml_stat_alloc in 4.06 ( 02a8b99 ); this breaks user code, as one should then use `caml_stat_free`. There is no use of caml_output_value_to_malloc in the runtime itself, so we do not need to provide a caml_output_value_to_stat_alloc variant.
505dee9
to
8774425
Compare
Thanks! I rebased the PR. |
OK for this change: ownership of the allocated block is transferred to 3rd-party C code, so the automatic deallocation that can occur with Symmetrically, there's |
Ah, good catch, I didn't know about that function and will change it as well. |
As you'll see it's a bit more difficult... |
I pushed a new commit to use |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! That was easier than I feared...
Thanks both, this is now merged. |
External users (unison, hhvm, pyre-check) assume that the memory they get from
caml_output_value_to_malloc
can be freed withfree
. (See #12491 (comment) for some user codebase examples .)The function was changed to use caml_stat_alloc in 4.06 ( 02a8b99 ); this breaks user code, as one should then use
caml_stat_free
.There is no use of caml_output_value_to_malloc in the runtime itself, so we do not need to provide a
caml_output_value_to_stat_alloc
variant.