Mallocator.reallocate

Increases or decreases the size of a memory block.

class Mallocator
bool
reallocate
(
ref void[] p
,
size_t size
)

Parameters

p void[]

A pointer to the memory block.

size size_t

Size of the reallocated block.

Return Value

Type: bool

Whether the reallocation was successful.

Examples

void[] p;

Mallocator.instance.reallocate(p, 20);
assert(p.length == 20);

Mallocator.instance.reallocate(p, 30);
assert(p.length == 30);

Mallocator.instance.reallocate(p, 10);
assert(p.length == 10);

Mallocator.instance.reallocate(p, 0);
assert(p is null);

Meta