Mallocator.reallocate

Increases or decreases the size of a memory block.

class Mallocator
@nogc nothrow pure shared @system
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;

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

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

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

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

Meta