use core::alloc::GlobalAlloc;
use core::ptr::NonNull;
#[cfg(feature = "allocator_api")]
use core::alloc::Allocator;
#[cfg(feature = "allocator_api")]
pub trait GlobalPallocConstraint = GlobalAlloc + Allocator;
#[cfg(not(feature = "allocator_api"))]
pub trait GlobalPallocConstraint = GlobalAlloc;
pub trait GlobalPalloc: GlobalPallocConstraint + Sized + Send {
fn new() -> Self;
unsafe fn init(&mut self, bottom: NonNull<u8>, size: usize);
unsafe fn init_from_slice(&mut self, heap: &mut [u8]);
unsafe fn new_initialized(bottom: NonNull<u8>, size: usize) -> Self {
let mut allocator = Self::new();
allocator.init(bottom, size);
allocator
}
unsafe fn new_from_slice(heap: &mut [u8]) -> Self {
let mut allocator = Self::new();
allocator.init_from_slice(heap);
allocator
}
}
pub mod unsafecell;
pub use self::unsafecell::UnsafeCellPalloc;
#[cfg(feature = "spin")]
pub mod spin;
#[cfg(feature = "spin")]
pub use self::spin::SpinPalloc;