Function swift_runtime_sys::root::swift::swift_allocObject

source ·
pub unsafe extern "C" fn swift_allocObject(
    metadata: *const HeapMetadata,
    requiredSize: usize,
    requiredAlignmentMask: usize,
) -> *mut HeapObject
Expand description

Allocates a new heap object. The returned memory is uninitialized outside of the heap-object header. The object has an initial retain count of 1, and its metadata is set to the given value.

At some point “soon after return”, it will become an invariant that metadata->getSize(returnValue) will equal requiredSize.

Either aborts or throws a swift exception if the allocation fails.

\param requiredSize - the required size of the allocation, including the header \param requiredAlignmentMask - the required alignment of the allocation; always one less than a power of 2 that’s at least alignof(void*) \return never null

POSSIBILITIES: The argument order is fair game. It may be useful to have a variant which guarantees zero-initialized memory.