Function

hylo_aligned_alloc(_:_:)

Allocates size bytes of uninitialized storage whose alignment is specified by alignment.

Source
fun hylo_aligned_alloc(
   _ alignment: Int,
   _ size: Int
) -> MemoryAddress

Details

This function is similar to aligned_alloc from libc, except that it accepts any non-negative size whereas aligned_alloc requires size to be an integral multiple of alignment. Use this function when you need memory aligned at a specific boundary. Othwewise, use malloc.

Memory allocated with hylo_aligned_alloc must be deallocated with hylo_aligned_free.

Returns

a pointer to newly allocated memory.

Parameters

alignment

The alignment of the allocated memory. Must be a power of 2.

size

The number of bytes to allocate. Must be greater than 0.