crate::ix!();
use core::alloc::{Allocator, Layout, AllocError};
use core::ptr::NonNull;
#[derive(Clone, Default)]
pub struct ZeroAfterFreeAllocator;
pub type SerializeData = Vec<u8, ZeroAfterFreeAllocator>;
unsafe impl Allocator for ZeroAfterFreeAllocator {
#[inline]
fn allocate(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
std::alloc::Global.allocate(layout)
}
#[inline]
fn allocate_zeroed(&self, layout: Layout) -> Result<NonNull<[u8]>, AllocError> {
std::alloc::Global.allocate_zeroed(layout)
}
#[inline]
unsafe fn deallocate(&self, ptr: NonNull<u8>, layout: Layout) {
crate::memory_cleanse(ptr.as_ptr() as *mut c_void, layout.size());
std::alloc::Global.deallocate(ptr, layout)
}
}