Allocates a T with context.allocator and returns a pointer to it. The value starts as the default for T.
Free it with free.
New :: ($T: Type, $initialized := true) -> *T
Parameters
- $T: Type
- $initialized := true
- set to
falseto skip setting the default; the bytes are then whatever the allocator returned.
Returns
- *T
Point :: struct { x := 1; y := 2; }
p := New(Point);
defer free(p);
assert(p.x == 1 && p.y == 2);