Container.Malloc

Malloc allocation manager.

Note that, due to GC behaviour, you should not configure a custom allocator for containers holding anything managed by the GC. For example, you cannot use a MallocAllocator to manage a container of classes or strings where those were allocated by the GC. Once something is owned by a GC then it's lifetime must be managed by GC-managed entities (otherwise the GC may think there are no live references and prematurely collect container contents).

You can explicity manage the collection of keys and values yourself by providing a reaper delegate. For example, if you use a MallocAllocator to manage key/value pairs which are themselves allocated via malloc, then you should also provide a reaper delegate to collect those as required.

Members

Functions

allocate
T* allocate()

allocate an array of T sized memory chunks

allocate
T*[] allocate(size_t count)

allocate an array of T sized memory chunks

collect
void collect(T*[] t)

Invoked when a specific T[] is discarded

collect
void collect(T* p)

Invoked when a specific T[] is discarded

collect
bool collect(bool all)

Invoked when clear/reset is called on the host. This is a shortcut to clear everything allocated.

config
void config(size_t chunks, int allocate)

set the chunk size and prepopulate with nodes

Meta