File_Utilities module

copy_to_permanent

procedureSource

A deep copy of path: the drive, every word and the array are new allocations from context.allocator, so the copy stays valid after the text it was parsed from is freed. Give it to free_permanent.

copy_to_permanent :: (path: Path) -> Path

Parameters

path: Path

Returns

Example↗
text := copy_string("x/y");
path := parse_path(text);
permanent := copy_to_permanent(path);
array_free(path.words);
free(text); // the copy no longer depends on it
assert(permanent.words.count == 2 && permanent.words[1] == "y");
free_permanent(permanent);

See also