Basic module

alloc_string

procedure · 1 overloadSource

A string of count bytes in newly allocated memory, with the context allocator. The bytes are not cleared, so write all of them before reading. Free it with free. With a count of 0 the string is empty and may have no data.

alloc_string :: (count: int) -> string

Parameters

count: int

Returns

string
ExampleOpen in playground ↗
s := alloc_string(3);
defer free(s);
memcpy(s.data, "abc".data, 3);
assert(s == "abc");

See also