pub fn allocate_aligned<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(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 uninitialized values.
/// This is more performant than using [allocate_aligned_zeroed] when all bytes will have
/// an unknown or non-zero value and is semantically similar to `malloc`.
Allocates a cache-aligned memory region of `size` bytes with uninitialized values.
This is more performant than using [allocate_aligned_zeroed] when all bytes will have
an unknown or non-zero value and is semantically similar to `malloc`.
Allocates a cache - aligned memory region of ` size ` bytes with uninitialized values . This is more performant than using [ allocate_aligned_zeroed ] when all bytes will have an unknown or non - zero value and is semantically similar to ` malloc ` .
pub fn allocate_aligned<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(layout) as *mut T;
            NonNull::new(raw_ptr).unwrap_or_else(|| handle_alloc_error(layout))
        }
    }
}
pub fn allocate_aligned < 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 ( 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 uninitialized values.
Allocates a cache - aligned memory region of ` size ` bytes with uninitialized values .
size
usize
size
usize