From: Brendan Hansen Date: Fri, 16 Jun 2023 21:11:47 +0000 (-0500) Subject: added: Allocator.move to move a value into an allocator X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=b76727aef1b6b7e7609fd081fbd1eea43ae5dd20;p=onyx.git added: Allocator.move to move a value into an allocator --- diff --git a/core/builtin.onyx b/core/builtin.onyx index 379cedd4..cdb3dc8f 100644 --- a/core/builtin.onyx +++ b/core/builtin.onyx @@ -267,6 +267,12 @@ raw_free :: (use a: Allocator, ptr: rawptr) { alloc :: raw_alloc resize :: raw_resize free :: raw_free + + move :: macro (use a: Allocator, v: $V) -> &V { + out := cast(&V) a->alloc(sizeof V); + *out = v; + return out; + } } //