Struct allocator_api::alloc::Global
source · pub struct Global;
Trait Implementations§
source§impl Alloc for Global
impl Alloc for Global
source§unsafe fn alloc(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr>
unsafe fn alloc(&mut self, layout: Layout) -> Result<NonNull<u8>, AllocErr>
Returns a pointer meeting the size and alignment guarantees of
layout
. Read moresource§unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout)
unsafe fn dealloc(&mut self, ptr: NonNull<u8>, layout: Layout)
Deallocate the memory referenced by
ptr
. Read moresource§unsafe fn realloc(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<NonNull<u8>, AllocErr>
unsafe fn realloc(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<NonNull<u8>, AllocErr>
Returns a pointer suitable for holding data described by
a new layout with
layout
’s alginment and a size given
by new_size
. To
accomplish this, this may extend or shrink the allocation
referenced by ptr
to fit the new layout. Read moresource§unsafe fn alloc_zeroed(
&mut self,
layout: Layout
) -> Result<NonNull<u8>, AllocErr>
unsafe fn alloc_zeroed(
&mut self,
layout: Layout
) -> Result<NonNull<u8>, AllocErr>
Behaves like
alloc
, but also ensures that the contents
are set to zero before being returned. Read moresource§fn usable_size(&self, layout: &Layout) -> (usize, usize)
fn usable_size(&self, layout: &Layout) -> (usize, usize)
Returns bounds on the guaranteed usable size of a successful
allocation created with the specified
layout
. Read moresource§unsafe fn alloc_excess(&mut self, layout: Layout) -> Result<Excess, AllocErr>
unsafe fn alloc_excess(&mut self, layout: Layout) -> Result<Excess, AllocErr>
Behaves like
alloc
, but also returns the whole size of
the returned block. For some layout
inputs, like arrays, this
may include extra storage usable for additional data. Read moresource§unsafe fn realloc_excess(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<Excess, AllocErr>
unsafe fn realloc_excess(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<Excess, AllocErr>
Behaves like
realloc
, but also returns the whole size of
the returned block. For some layout
inputs, like arrays, this
may include extra storage usable for additional data. Read moresource§unsafe fn grow_in_place(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<(), CannotReallocInPlace>
unsafe fn grow_in_place(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<(), CannotReallocInPlace>
source§unsafe fn shrink_in_place(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<(), CannotReallocInPlace>
unsafe fn shrink_in_place(
&mut self,
ptr: NonNull<u8>,
layout: Layout,
new_size: usize
) -> Result<(), CannotReallocInPlace>
source§fn alloc_one<T>(&mut self) -> Result<NonNull<T>, AllocErr>where
Self: Sized,
fn alloc_one<T>(&mut self) -> Result<NonNull<T>, AllocErr>where
Self: Sized,
Allocates a block suitable for holding an instance of
T
. Read moresource§unsafe fn dealloc_one<T>(&mut self, ptr: NonNull<T>)where
Self: Sized,
unsafe fn dealloc_one<T>(&mut self, ptr: NonNull<T>)where
Self: Sized,
Deallocates a block suitable for holding an instance of
T
. Read more