pub struct TestAlloc<A>where
A: GlobalAlloc,{ /* private fields */ }
Expand description
TestAlloc
is a implementation for GlobalAlloc
to test memory leak and so on.
It is a wrapper of another GlobalAlloc
, and checks the requests delegating to the backend
allocator.
The checks are followings.
- The argument
*mut u8
passed todealloc
is not null. (GlobalAlloc
interface does not define the behavior.) - The consistency of the argument
Layout
. i.e. the argument passed todealloc
must matche to that passed toalloc
to return the corresponding pointer. - All allocated memories have already been deallocated on the drop. (Note that cloned instances share the allocating memory information. The check is done when the last cloned instance is dropped.)
See also GAlloc
. It is an alias to TestAlloc<std::alloc::System>
.
Implementations§
source§impl<A> TestAlloc<A>where
A: GlobalAlloc,
impl<A> TestAlloc<A>where A: GlobalAlloc,
Trait Implementations§
source§impl<A> Drop for TestAlloc<A>where
A: GlobalAlloc,
impl<A> Drop for TestAlloc<A>where A: GlobalAlloc,
source§impl<A> From<A> for TestAlloc<A>where
A: GlobalAlloc,
impl<A> From<A> for TestAlloc<A>where A: GlobalAlloc,
source§impl<A> GlobalAlloc for TestAlloc<A>where
A: GlobalAlloc,
impl<A> GlobalAlloc for TestAlloc<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