stabby_abi/alloc/allocators/mod.rs
1#[cfg(all(feature = "libc", not(target_arch = "wasm32")))]
2/// [`IAlloc`](crate::alloc::IAlloc) bindings for `libc::malloc`
3pub(crate) mod libc_alloc;
4#[cfg(all(feature = "libc", not(target_arch = "wasm32")))]
5pub use libc_alloc::LibcAlloc;
6
7#[cfg(feature = "alloc-rs")]
8/// Rust's GlobalAlloc, accessed through a vtable to ensure no incompatible function calls are performed
9mod rust_alloc;
10#[cfg(feature = "alloc-rs")]
11pub use rust_alloc::RustAlloc;
12
13#[cfg(stabby_default_alloc = "RustAlloc")]
14/// The default allocator, depending on which of the following is available:
15/// - RustAlloc: Rust's `GlobalAlloc`, through a vtable that ensures FFI-safety.
16/// - LibcAlloc: libc::malloc, which is 0-sized.
17/// - None. I _am_ working on getting a 0-dependy allocator working, but you should probably go with `feature = "alloc-rs"` anyway.
18///
19/// You can also use the `stabby_default_alloc` cfg to override the default allocator regardless of feature flags.
20pub(crate) type DefaultAllocator = RustAlloc;
21
22#[cfg(stabby_default_alloc = "LibcAlloc")]
23/// The default allocator, depending on which of the following is available:
24/// - RustAlloc: Rust's `GlobalAlloc`, through a vtable that ensures FFI-safety.
25/// - LibcAlloc: libc::malloc, which is 0-sized.
26/// - None. I _am_ working on getting a 0-dependy allocator working, but you should probably go with `feature = "alloc-rs"` anyway.
27///
28/// You can also use the `stabby_default_alloc` cfg to override the default allocator regardless of feature flags.
29pub(crate) type DefaultAllocator = LibcAlloc;
30
31#[cfg(stabby_default_alloc = "disabled")]
32/// The default allocator, depending on which of the following is available:
33/// - RustAlloc: Rust's `GlobalAlloc`, through a vtable that ensures FFI-safety.
34/// - LibcAlloc: libc::malloc, which is 0-sized.
35/// - None. I _am_ working on getting a 0-dependy allocator working, but you should probably go with `feature = "alloc-rs"` anyway.
36///
37/// You can also use the `stabby_default_alloc` cfg to override the default allocator regardless of feature flags.
38pub(crate) type DefaultAllocator = core::convert::Infallible;