#![cfg(all(feature = "allocator", not(feature = "allocation-tracking")))]
use std::alloc::{GlobalAlloc, Layout, System};
pub struct NotrackAlloc<Alloc = System> {
alloc: Alloc,
}
impl<A> NotrackAlloc<A> {
#[inline]
pub const fn new(alloc: A) -> Self {
Self {
alloc,
}
}
}
impl<A: GlobalAlloc> NotrackAlloc<A> {
pub fn memory_allocated(&self) -> usize {
0
}
pub fn flush_local_allocations(&self) {
}
pub fn is_beyond_threshold(&self) -> bool {
false
}
}
unsafe impl<A: GlobalAlloc> GlobalAlloc for NotrackAlloc<A> {
unsafe fn alloc(&self, layout: Layout) -> *mut u8 {
unsafe { self.alloc.alloc(layout) }
}
unsafe fn alloc_zeroed(&self, layout: Layout) -> *mut u8 {
unsafe { self.alloc.alloc_zeroed(layout) }
}
unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) {
unsafe { self.alloc.dealloc(ptr, layout) };
}
unsafe fn realloc(&self, ptr: *mut u8, layout: Layout, new_size: usize) -> *mut u8 {
unsafe { self.alloc.realloc(ptr, layout, new_size) }
}
}