GC.addRange

void addRange(const void * p, size_t sz, const TypeInfo ti = null) @nogc nothrow pure;

Adds p[0 .. sz] to the list of memory ranges to be scanned for pointers during a collection. If p is null, no operation is performed.

Note that p[0 .. sz] is treated as an opaque range of memory assumed to be suitably managed by the caller. In particular, if p points into a GC-managed memory block, addRange does not mark this block as live.

Parameters

pA pointer to a valid memory address or to null.
szThe size in bytes of the block to add. If sz is zero then the no operation will occur. If p is null then sz must be zero.
tiTypeInfo to describe the memory. The GC might use this information to improve scanning for pointers or to call finalizers Example:
// Allocate a piece of memory on the C heap.
enum size = 1_000;
auto rawMemory = core.stdc.stdlib.malloc(size);

// Add it as a GC range.
GC.addRange(rawMemory, size);

// Now, pointers to GC-managed memory stored in
// rawMemory will be recognized on collection.