Struct gharial::MaybeAlloc
source · pub struct MaybeAlloc<A = TestAlloc<System>>where
A: GlobalAlloc,{ /* private fields */ }
Expand description
MaybeAlloc
is an implementation for GlobalAlloc
, which occasionally fails to allocate.
It is a wrapper of another GlobalAlloc
, and delegates the requests to the inner, however, sometimes fails to allocate
memory on purpose. i.e. MaybeAlloc::alloc
can return null pointer before memory exhaustion.
The failure properbility is 1/16.
Trait Implementations§
source§impl<A> Clone for MaybeAlloc<A>where
A: GlobalAlloc + Clone,
impl<A> Clone for MaybeAlloc<A>where A: GlobalAlloc + Clone,
source§impl<A> Debug for MaybeAlloc<A>where
A: GlobalAlloc + Debug,
impl<A> Debug for MaybeAlloc<A>where A: GlobalAlloc + Debug,
source§impl<A> Default for MaybeAlloc<A>where
A: GlobalAlloc + Default,
impl<A> Default for MaybeAlloc<A>where A: GlobalAlloc + Default,
source§impl<A> From<A> for MaybeAlloc<A>where
A: GlobalAlloc,
impl<A> From<A> for MaybeAlloc<A>where A: GlobalAlloc,
source§impl<A> GlobalAlloc for MaybeAlloc<A>where
A: GlobalAlloc,
impl<A> GlobalAlloc for MaybeAlloc<A>where A: GlobalAlloc,
source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
Allocate memory as described by the given
layout
. Read more