use crate::*;
use crate::meta::*;
use super::ffi;
use core::ptr::NonNull;
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)] #[repr(transparent)] pub struct NewDeleteArray;
impl Meta for NewDeleteArray {
type Error = ();
const MAX_ALIGN : Alignment = if !cfg!(target_env = "msvc") {
Alignment::of::<f64>() } else if core::mem::size_of::<usize>() >= 8 {
ALIGN_16
} else {
ALIGN_8
};
const MAX_SIZE : usize = usize::MAX; const ZST_SUPPORTED : bool = false; }
unsafe impl Stateless for NewDeleteArray {}
unsafe impl thin::Alloc for NewDeleteArray {
fn alloc_uninit(&self, size: usize) -> Result<AllocNN, Self::Error> {
NonNull::new(unsafe { ffi::operator_new_array_nothrow(size) }.cast()).ok_or(())
}
}
unsafe impl thin::Free for NewDeleteArray {
unsafe fn free_nullable(&self, ptr: *mut core::mem::MaybeUninit<u8>) {
unsafe { ffi::operator_delete_array(ptr.cast()) };
}
}
unsafe impl fat::Realloc for NewDeleteArray {}
#[no_implicit_prelude] mod cleanroom {
use super::{impls, NewDeleteArray};
impls! {
unsafe impl ialloc::fat::Alloc for NewDeleteArray => ialloc::thin::Alloc;
unsafe impl ialloc::fat::Free for NewDeleteArray => ialloc::thin::Free;
}
}
#[test] fn thin_alignment() { thin::test::alignment(NewDeleteArray) }
#[test] fn thin_edge_case_sizes() { thin::test::edge_case_sizes(NewDeleteArray) }
#[test] fn thin_nullable() { thin::test::nullable(NewDeleteArray) }
#[test] fn thin_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { thin::test::uninit_alloc_unsound(NewDeleteArray) } } }
#[test] fn thin_zeroed() { thin::test::zeroed_alloc(NewDeleteArray) }
#[test] fn thin_zst_support() { thin::test::zst_supported_conservative(NewDeleteArray) }
#[test] fn fat_alignment() { fat::test::alignment(NewDeleteArray) }
#[test] fn fat_edge_case_sizes() { fat::test::edge_case_sizes(NewDeleteArray) }
#[test] fn fat_uninit() { if !allocator::cpp::OPERATOR_NEW_ZERO_INITS { unsafe { fat::test::uninit_alloc_unsound(NewDeleteArray) } } }
#[test] fn fat_uninit_realloc() { fat::test::uninit_realloc(NewDeleteArray) }
#[test] fn fat_zeroed() { fat::test::zeroed_alloc(NewDeleteArray) }
#[test] fn fat_zeroed_realloc() { fat::test::zeroed_realloc(NewDeleteArray) }
#[test] fn fat_zst_support() { fat::test::zst_supported_conservative(NewDeleteArray) }