Basic module

array_reset

procedure · 2 overloadsSource

Frees the storage of an array (as array_free does) and sets the array to empty, so it can be reused.

Safe on an array that never allocated. The elements themselves are not freed.

ExampleOpen in playground ↗
values: [..] int;
array_add(*values, 1, 2, 3);
array_reset(*values);
assert(values.count == 0 && values.data == null);
array_reset :: (array: *[] $T)

Frees the storage of an array (as array_free does) and sets the array to empty, so it can be reused.

Safe on an array that never allocated. The elements themselves are not freed.

Parameters

array: *[] $T
ExampleOpen in playground ↗
values: [..] int;
array_add(*values, 1, 2, 3);
array_reset(*values);
assert(values.count == 0 && values.data == null);
array_reset :: (array: *[..] $T)

Frees a dynamic array through its own allocator and sets it to empty, which also forgets that allocator.

Parameters

array: *[..] $T

See also