Expose most of mimalloc API from libmimalloc-sys #32
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
Fixes #31. Comes with tests, more CI, and docs.
This goes on top of #30 since it improves the CI. It also includes the fix for #29 which is a one-liner and is required to make the tests pass.
Once #30 that lands I'll rebase and the commits from it should go away, and if you like the look at this I can close #29 and just let it get subsumed.
This splits stuff into an "extended" API (activated by a feature) and a default API. This is a bit odd, since it's not really on a good/deliberate boundary.
I think perhaps a better boundary would be:
mimalloc::MimallocimplementationAs it is it's kind of weird that it includes
mi_zallocormi_usable_sizein the "core", butmi_callocis part of the extended api. That said, the code is probably fine as-is -- it would be breaking to move public stuff behind a feature, and really there's little benefit to it, so it seems fine, just odd.What this skips:
I'm not that attached to most of the things on this list, and would be willing to add them either now or in the future as-needed.
Anyway, the following parts of the API are intentionally not exposed because they
The C++ wrappers as they're just the normal mimalloc API but with throwing C++ exceptions on failure, which is probably unsound.
The Posix functions as they're all aliases or tiny wrappers for the normal mimalloc API.
All of these not captured by Posix/C++ (above).
The Typed Macros for obvious reasons.
The Zero initialized re-allocation functions as they're easy to misuse (only valid on pointers coming from a zero-init alloc function in the first place).
Anything labeled experimental, which is:
Most of the
optionenums (note that the docs for them are sadly a bit out of date too... Documentation is out of date (e.g. mi_option_enable()) microsoft/mimalloc#266). Users can make their own constants if they need these, which honestly seems unlikely.Also
mi_is_in_heap_region,mi_is_redirected,mi_reserve_huge_os_pages_interleave,mi_reserve_huge_os_pages_at.Anything deprecated, e.g.
mi_reserve_huge_os_pages.I'm also omitting a few other functions that are not very useful and have potential to cause problems:
mi_option_enable/mi_option_disable: Just a wrapper formi_option_set_enabled, and had a different argument count in the pastIn practice this seems unlikely to matter, but given that they're just wrappers, no reason to risk it in case this crate allows linking to an external mimalloc in the future, and we get an older one.
I think that's it.
Looking at it again, zero initialized re-allocation is probably worth adding -- it's a low level API and that can help. It's easy to misuse, but that's why it's
unsafe.Hrm.