Variant module

free_variant

procedureextensionsince 0.29.0Source

Releases the memory the live case owns, with free: strings, resizable arrays (and what their elements own), and the same inside structs and nested variants. Views ([] T) and pointers are not owned and are left alone. Then the variant is zeroed: its first case, zeroed. Only use it on payloads that came from the allocator, not string literals.

Example↗
#import "Extensions/Variant";

id := variant(Variant(s64, string), copy_string("owned"));
free_variant(*id);
assert(is(id, s64));
free_variant :: (v: *$V/Variant)

Parameters

v: *$V/Variant

See also