Basic module

copy_string

procedure · 1 overloadSource

A copy of s in newly allocated memory, with the context allocator. Free it with free. Use copy_temporary_string for a copy that needs no freeing.

copy_string :: (s: string) -> string

Parameters

s: string

Returns

string
ExampleOpen in playground ↗
original := "text";
copy := copy_string(original);
defer free(copy);
assert(copy == original && copy.data != original.data);

See also