2 releases
new 0.1.1 | Apr 14, 2025 |
---|---|
0.1.0 | Apr 14, 2025 |
#198 in Memory management
153 downloads per month
78KB
1.5K
SLoC
A re-imagining of allocation in Rust from the ground-up. Fully no_std
and
portable.
Everything is built on top of the Allocator
trait (and
AllocatorExt
); the goal is to make allocation itself 100% safe. To that
end, it introduces the Alloc
abstraction to ensure no allocation is
double-freed or freed in the wrong allocator.
A secondary (but still very important) goal is genericity. For this, all built-in allocations are fully generic over what allocator they use, as well as the strategy used to handle allocation failures.
The feature flag global
enables the global allocator framework,
which allows one to set an allocator for all collections to use by default.
The crate comes with built-in system allocators for Linux (via
aligned_alloc
) and Windows (_aligned_malloc
), but only with feature
platform
enabled. (with both global
and platform
, the global allocator
is initially the platform allocator)
A number of containers are defined in the crate (at the time of writing,
[Box
] and [Vec
], to varying degrees of completeness). Note that Box
is
somewhat different to std::box::Box
, due to the lack of compiler magic.
It also provides certain portable predefined allocators (currently Arena
and Array
). Of course, you can always define your own, and use them just
the same.
Note that while the whole crate is no_std
, and aside from platform
is
totally portable, it does make use of core::sync::atomic
. If your
desired platform doesn't support atomics at all, this crate will not work.
Dependencies
~91KB