#[non_exhaustive]
pub enum Event {
Alloc(Request),
Free(Request),
AllocZeroed(AllocZeroed),
Realloc(Realloc),
AllocFailed,
AllocZeroedFailed,
ReallocNull(ReallocNull),
ReallocFailed,
}
Expand description
Metadata for a single allocation or deallocation.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Alloc(Request)
An allocation.
Free(Request)
A deallocation.
AllocZeroed(AllocZeroed)
A zerod allocation, with an optional boolean indicates if it is actually zeroed or not.
Realloc(Realloc)
A reallocation that moves and resized memory from one location to another.
AllocFailed
An allocation failed (produced null).
AllocZeroedFailed
A zero allocation that failed (produced null).
ReallocNull(ReallocNull)
Allocator was asked to reallocate unallocated memory.
ReallocFailed
A reallocation failed (produced null), and the previous region is left unchanged.
Implementations§
source§impl Event
impl Event
sourcepub fn is_alloc_with<F>(&self, f: F) -> boolwhere
F: FnOnce(Region) -> bool,
pub fn is_alloc_with<F>(&self, f: F) -> boolwhere F: FnOnce(Region) -> bool,
Test if this event is an allocation which matches the specified predicate.
Examples
use checkers::{Event::*, Request, Region};
let request = Request::without_backtrace(Region::new(100.into(), 100, 4));
let event = Alloc(request);
assert!(event.is_alloc_with(|r| r.size == 100 && r.align == 4));
assert!(!event.is_free_with(|r| r.size == 100 && r.align == 4));
sourcepub fn is_free_with<F>(&self, f: F) -> boolwhere
F: FnOnce(Region) -> bool,
pub fn is_free_with<F>(&self, f: F) -> boolwhere F: FnOnce(Region) -> bool,
Test if this event is a deallocation which matches the specified predicate.
Examples
use checkers::{Event::*, Region, Request};
let request = Request::without_backtrace(Region::new(100.into(), 100, 4));
let event = Free(request);
assert!(!event.is_alloc_with(|r| r.size == 100 && r.align == 4));
assert!(event.is_free_with(|r| r.size == 100 && r.align == 4));
sourcepub fn is_alloc_zeroed_with<F>(&self, f: F) -> boolwhere
F: FnOnce(&AllocZeroed) -> bool,
pub fn is_alloc_zeroed_with<F>(&self, f: F) -> boolwhere F: FnOnce(&AllocZeroed) -> bool,
Test if this event is an allocation which matches the specified predicate.
Examples
use checkers::{Event::*, Request, Region, AllocZeroed};
let event = AllocZeroed(AllocZeroed::new(
Some(true),
Request::without_backtrace(Region::new(100.into(), 100, 4))
));
assert!(event.is_alloc_zeroed_with(|r| r.request.region.size == 100 && r.request.region.align == 4));
assert!(!event.is_free_with(|r| r.size == 100 && r.align == 4));
sourcepub fn is_realloc_with<F>(&self, f: F) -> boolwhere
F: FnOnce(&Realloc) -> bool,
pub fn is_realloc_with<F>(&self, f: F) -> boolwhere F: FnOnce(&Realloc) -> bool,
Test if this event is an allocation which matches the specified predicate.
Examples
use checkers::{Event::*, Realloc, Region, Request};
let event = Realloc(Realloc::without_backtrace(
Some(true),
Region::new(10.into(), 10, 1),
Region::new(20.into(), 20, 1)
));
assert!(event.is_realloc_with(|r| r.free.size == 10 && r.alloc.size == 20));