#[repr(C)]pub struct RawMalloc<T: Grower> { /* private fields */ }
Expand description
A single threaded memory allocator.
Implementations§
Source§impl<T: Grower> RawMalloc<T>
impl<T: Grower> RawMalloc<T>
Sourcepub const unsafe fn with_grower(grower: T) -> Self
pub const unsafe fn with_grower(grower: T) -> Self
Creates an allocator instance with the specified grower.
§Safety
Callers must make sure that the provided grower will be the only object managing it’s underlying buffer for the lifetime of the returned allocator.
Trait Implementations§
Source§impl<T: Grower> Allocator for RawMalloc<T>
impl<T: Grower> Allocator for RawMalloc<T>
Source§fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)Attempts to allocate a block of memory. Read more
Source§unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout)
🔬This is a nightly-only experimental API. (
allocator_api
)Deallocates the memory referenced by
ptr
. Read moreSource§unsafe fn grow(
&self,
obj_start: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, obj_start: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)Attempts to extend the memory block. Read more
Source§unsafe fn shrink(
&self,
obj_start: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn shrink( &self, obj_start: NonNull<u8>, old_layout: Layout, new_layout: Layout, ) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)Attempts to shrink the memory block. Read more
Source§fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError>
🔬This is a nightly-only experimental API. (
allocator_api
)Behaves like
allocate
, but also ensures that the returned memory is zero-initialized. Read moreSource§impl<T: Grower> GlobalAlloc for RawMalloc<T>
impl<T: Grower> GlobalAlloc for RawMalloc<T>
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocates memory as described by the given
layout
. Read moreimpl<T: Grower> Eq for RawMalloc<T>
Auto Trait Implementations§
impl<T> !Freeze for RawMalloc<T>
impl<T> !RefUnwindSafe for RawMalloc<T>
impl<T> !Send for RawMalloc<T>
impl<T> !Sync for RawMalloc<T>
impl<T> Unpin for RawMalloc<T>where
T: Unpin,
impl<T> UnwindSafe for RawMalloc<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more