pub struct SpinLockedAllocator(_);Expand description
A spin locked memory allocator that can be used as the global allocator.
Implementations
sourceimpl SpinLockedAllocator
impl SpinLockedAllocator
sourcepub const fn empty() -> Self
pub const fn empty() -> Self
Creates an empty locked heap allocator without any heap memory region, which will always return null on allocation requests.
To intiialize this allocator, use the init method.
sourcepub unsafe fn init(&self, heap_start_addr: usize, heap_size: usize)
pub unsafe fn init(&self, heap_start_addr: usize, heap_size: usize)
Initializes the heap allocator with the given memory region.
Safety
If the allocator was already initialized, this function will panic.
The SpinLockedAllocator on which this was called must not be moved,
and its address in memory must not change, otherwise undefined
behaviour will occur. This is because the heap region now contains
pointers to fields of this struct, and if this struct will move, the
address of its fields will change, and those pointers will now be
invalid.
The provided memory region must be valid and non-null, and must not be used by anything else.
If after aligning the start and end addresses, the size of the heap is 0, the function panics.
Trait Implementations
sourceimpl GlobalAlloc for SpinLockedAllocator
impl GlobalAlloc for SpinLockedAllocator
sourceunsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout. Read more