From b76727aef1b6b7e7609fd081fbd1eea43ae5dd20 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 16 Jun 2023 16:11:47 -0500 Subject: [PATCH] added: Allocator.move to move a value into an allocator --- core/builtin.onyx | 6 ++++++ 1 file changed, 6 insertions(+) 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; + } } // -- 2.25.1