Function aligned_alloc::aligned_alloc [] [src]

pub fn aligned_alloc(size: usize, align: usize) -> *mut ()

Allocates size Bytes aligned to align Bytes. Returns a null pointer on allocation failure.

The returned pointer must be deallocated by using aligned_free.

Note: This function is meant to be used for infrequent large allocations (as malloc already guarantees suitable alignment for all native datatypes) and might be quite slow when used heavily.

Parameters

  • size: The size of the allocation in bytes.
  • align: The alignment of the allocation (at least the size of usize on the current platform). Must also be a power of two.