AllocHooks

Trait AllocHooks 

Source
pub unsafe trait AllocHooks {
    // Required methods
    fn on_alloc(&self, pointer: *mut u8, size: usize, align: usize);
    fn on_dealloc(&self, pointer: *mut u8, size: usize, align: usize);
    fn on_alloc_zeroed(&self, pointer: *mut u8, size: usize, align: usize);
    fn on_realloc(
        &self,
        old_pointer: *mut u8,
        new_pointer: *mut u8,
        old_size: usize,
        new_size: usize,
        align: usize,
    );
}
Expand description

Trait for implementing allocation hooks in a tracing allocator.

§Safety

Implementors must ensure that hook methods do not allocate memory (to avoid infinite recursion) and are safe to call from any thread at any time during allocation operations.

Required Methods§

Source

fn on_alloc(&self, pointer: *mut u8, size: usize, align: usize)

Source

fn on_dealloc(&self, pointer: *mut u8, size: usize, align: usize)

Source

fn on_alloc_zeroed(&self, pointer: *mut u8, size: usize, align: usize)

Source

fn on_realloc( &self, old_pointer: *mut u8, new_pointer: *mut u8, old_size: usize, new_size: usize, align: usize, )

Implementors§