Table of Contents

Class Allocation

Namespace
Garyon.Memory
Assembly
Garyon.dll

Provides functions for memory allocation on the unmanaged heap.

[ExcludeFromCodeCoverage]
public static class Allocation
Inheritance
Allocation
Inherited Members

Methods

Allocate(int)

Allocates a block of bytes from the unmanaged heap.

public static void* Allocate(int bytes)

Parameters

bytes int

The number of bytes to allocate.

Returns

void*

A void* pointing to the start of the allocated block.

AllocateClear(int)

Allocates a block of bytes from the unmanaged heap, and zeroes it.

public static void* AllocateClear(int bytes)

Parameters

bytes int

The number of bytes to allocate.

Returns

void*

A void* pointing to the start of the allocated block.

AllocateClear<T>(int)

Allocates a block of elements of a specified type T from the unmanaged heap, and zeroes it.

public static T* AllocateClear<T>(int elements) where T : unmanaged

Parameters

elements int

The number of elements the allocated block will store.

Returns

T*

A T* pointing to the start of the allocated block. The block's size is equal to the number of elements multiplied by sizeof(T).

Type Parameters

T

The type of elements the allocated block will store.

Allocate<T>(int)

Allocates a block of elements of a specified type T from the unmanaged heap.

public static T* Allocate<T>(int elements) where T : unmanaged

Parameters

elements int

The number of elements the allocated block will store.

Returns

T*

A T* pointing to the start of the allocated block. The block's size is equal to the number of elements multiplied by sizeof(T).

Type Parameters

T

The type of elements the allocated block will store.

Free(void*)

Frees a previously allocated block of bytes from the unmanaged heap.

public static void Free(void* pointer)

Parameters

pointer void*

The void* pointing at the block that was allocated.

Reallocate(void*, int)

Reallocates a block of bytes from the unmanaged heap.

public static void* Reallocate(void* pointer, int bytes)

Parameters

pointer void*

The pointer to the original block that will be reallocated.

bytes int

The number of bytes of the newly allocated block.

Returns

void*

A void* pointing to the start of the reallocated block.

Reallocate<T>(T*, int)

Reallocates a block of elements from the unmanaged heap.

public static T* Reallocate<T>(T* pointer, int elements) where T : unmanaged

Parameters

pointer T*

The pointer to the original block that will be reallocated.

elements int

The number of elements of the newly allocated block.

Returns

T*

A T* pointing to the start of the reallocated block. The block's size is equal to the number of elements multiplied by sizeof(T).

Type Parameters

T