Struct MmapAllocator

Source
pub struct MmapAllocator;
Expand description

Implementation of std::alloc::GlobalAlloc whose backend is mmap(2)

Implementations§

Source§

impl MmapAllocator

Source

pub const fn new() -> Self

Creates a new instance.

Trait Implementations§

Source§

impl Clone for MmapAllocator

Source§

fn clone(&self) -> MmapAllocator

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for MmapAllocator

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for MmapAllocator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl GlobalAlloc for MmapAllocator

§Portability

alloc() calls mmap() with flag MAP_ANONYMOUS. Many systems support the flag, however, it is not specified in POSIX.

§Safety

All functions are thread safe.

§Error

Each function don’t cause panic but set OS errno on error.

Note that it is not an error to deallocate pointer which is not allocated. This is the spec of munmap(2). See man 2 munmap for details.

Source§

unsafe fn alloc(&self, layout: Layout) -> *mut u8

§Panics

This method may panic if the align of layout is greater than the kernel page align. (Basically, kernel page align is always greater than the align of layout that rust generates unless the programer dares to build such a layout on purpose.)

Source§

unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8

§Panics

This method can panic if the align of layout is greater than the kernel page align.

Source§

unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)

Deallocates the block of memory at the given ptr pointer with the given layout. Read more
1.28.0 · Source§

unsafe fn realloc( &self, ptr: *mut u8, layout: Layout, new_size: usize, ) -> *mut u8

Shrinks or grows a block of memory to the given new_size in bytes. The block is described by the given ptr pointer and layout. Read more
Source§

impl Copy for MmapAllocator

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.