/// Allocates a cache-aligned memory region of `size` bytes with `0` on all of them.
/// This is more performant than using [allocate_aligned] and setting all bytes to zero
/// and is semantically similar to `calloc`.
Allocates a cache-aligned memory region of `size` bytes with `0` on all of them.
This is more performant than using [allocate_aligned] and setting all bytes to zero
and is semantically similar to `calloc`.
Allocates a cache - aligned memory region of ` size ` bytes with ` 0 ` on all of them . This is more performant than using [ allocate_aligned ] and setting all bytes to zero and is semantically similar to ` calloc ` .
pub fn allocate_aligned_zeroed<T: NativeType>(size: usize) -> NonNull<T> {
    unsafe {
        if size == 0 {
            dangling()
        } else {
            let size = size * size_of::<T>();
            ALLOCATIONS.fetch_add(size as isize, std::sync::atomic::Ordering::SeqCst);
            let layout = Layout::from_size_align_unchecked(size, ALIGNMENT);
            let raw_ptr = std::alloc::alloc_zeroed(layout) as *mut T;
            NonNull::new(raw_ptr).unwrap_or_else(|| handle_alloc_error(layout))
        }
    }
}
pub fn allocate_aligned_zeroed < T : NativeType > ( size : usize ) -> NonNull < T > { unsafe { if size == 0 { dangling ( ) } else { let size = size * size_of :: < T > ( ) ; ALLOCATIONS . fetch_add ( size as isize , std :: sync :: atomic :: Ordering :: SeqCst ) ; let layout = Layout :: from_size_align_unchecked ( size , ALIGNMENT ) ; let raw_ptr = std :: alloc :: alloc_zeroed ( layout ) as * mut T ; NonNull :: new ( raw_ptr ) . unwrap_or_else ( | | handle_alloc_error ( layout ) ) } } }
Allocates a cache-aligned memory region of `size` bytes with `0` on all of them.
Allocates a cache - aligned memory region of ` size ` bytes with ` 0 ` on all of them .
size
usize