allocate
Functions: allocate, safeAllocate, allocateArray, safeAllocateArray, deallocate
allocate
Type* allocate<Type>(Type value)Allocates a block of dynamic memory to hold the given value, moves
the value into the memory block, and returns a pointer to it. The block
can be freed by passing the returned pointer to a call to
deallocate.
If the memory allocation fails, the program crashes (when compiled in checked mode) or invokes undefined behavior (when compiled in unchecked mode).
safeAllocate
Type*? safeAllocate<Type>(Type value)Allocates a block of dynamic memory to hold the given value, moves
the value into the memory block, and returns a pointer to it. The block
can be freed by passing the returned pointer to a call to
deallocate.
If the memory allocation fails, null is returned.
allocateArray
Type[*] allocateArray<Type>(int size)Allocates a block of dynamic memory to hold an array with the given
element type and size, and returns a pointer to the array. The elements
of the array are uninitialized. The block can be freed by passing the
returned pointer to a call to deallocate.
If the memory allocation fails, the program crashes (when compiled in checked mode) or invokes undefined behavior (when compiled in unchecked mode).
safeAllocateArray
Type[*]? safeAllocateArray<Type>(int size)Allocates a block of dynamic memory to hold an array with the given
element type and size, and returns a pointer to the array. The elements
of the array are uninitialized. The block can be freed by passing the
returned pointer to a call to deallocate.
If the memory allocation fails, null is returned.
deallocate
void deallocate<Type>(Type allocation)Deallocates a block of dynamic memory that was previously allocated
by a call to allocate, allocateArray,
safeAllocate, or safeAllocateArray. If the
argument is null, no operation is performed.