pub struct Allocator<T>(pub T);Expand description
A global allocator that forwards to System and tells its Tally of
each block made or freed on a counted thread: of a request before
System sees it (Tally::growing, undone by Tally::failed), and
of its block once System has answered: a failure counts nothing, and a realloc that fails leaves its
old block live and counted. A growing realloc that succeeds counts its
new block before it frees the old one, the worst case of a moving
realloc: both blocks live at once. A shrinking one frees the old block
first, since glibc shrinks in place, unless System allocates, copies
and frees instead (an alignment over malloc’s, or a new size below the
alignment), which counts as a growth does: the engine’s allocator’s
rule (unityrs_batch::alloc). A tally that panics aborts the process
(Tally). A test file installs it with its own tally:
#[global_allocator] static ALLOC: Allocator<Mine> = Allocator(Mine);.
Tuple Fields§
§0: TTrait Implementations§
Source§impl<T: Tally> GlobalAlloc for Allocator<T>
impl<T: Tally> GlobalAlloc for Allocator<T>
Source§unsafe fn alloc(&self, layout: Layout) -> *mut u8
unsafe fn alloc(&self, layout: Layout) -> *mut u8
layout. Read moreSource§unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8
alloc, but also ensures that the contents
are set to zero before being returned. Read more