#[repr(C)]pub struct RustyMalloc<T: Grower> { /* private fields */ }
Expand description
A multithreaded memory allocator.
This allocator is just a Mutex
wrapper over RawMalloc
to allow for multithreading.
Implementations§
Source§impl<T: Grower> RustyMalloc<T>
impl<T: Grower> RustyMalloc<T>
Sourcepub const unsafe fn with_grower(grower: T) -> Self
pub const unsafe fn with_grower(grower: T) -> Self
§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 RustyMalloc<T>
impl<T: Grower> Allocator for RustyMalloc<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,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn grow( &self, ptr: 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,
ptr: NonNull<u8>,
old_layout: Layout,
new_layout: Layout,
) -> Result<NonNull<[u8]>, AllocError>
unsafe fn shrink( &self, ptr: 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 RustyMalloc<T>
impl<T: Grower> GlobalAlloc for RustyMalloc<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 moreSource§impl<T: Grower> PartialEq for RustyMalloc<T>
impl<T: Grower> PartialEq for RustyMalloc<T>
impl<T: Grower> Eq for RustyMalloc<T>
impl<T: Grower> Sync for RustyMalloc<T>
Auto Trait Implementations§
impl<T> !Freeze for RustyMalloc<T>
impl<T> RefUnwindSafe for RustyMalloc<T>
impl<T> !Send for RustyMalloc<T>
impl<T> Unpin for RustyMalloc<T>where
T: Unpin,
impl<T> UnwindSafe for RustyMalloc<T>
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