From: Brendan Hansen Date: Thu, 9 Mar 2023 00:54:17 +0000 (-0600) Subject: changed: `make` and `delete` no longer have pointer implementations X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=536b2ab09a51d8e772d22443278eb60e122a0bf0;p=onyx.git changed: `make` and `delete` no longer have pointer implementations --- diff --git a/core/builtin.onyx b/core/builtin.onyx index af99c4ca..aa5402c8 100644 --- a/core/builtin.onyx +++ b/core/builtin.onyx @@ -346,24 +346,9 @@ cfree :: (ptr: rawptr) => raw_free(context.allocator, ptr); // // See core/container/array.onyx for an example. // - __make_overload :: #match { - // - // This is the fallback option for make. It simply allocates a zero-intialized - // element of type T. - #order 1000 (_: &$T, allocator := context.allocator) -> &T { - memory :: package core.memory - - res := cast(&T) raw_alloc(allocator, sizeof T); - memory.set(res, 0, sizeof T); - return res; - }, - } + __make_overload :: #match {} - delete :: #match { - #order 1000 macro (x: &$T, allocator := context.allocator) { - if x != null do raw_free(allocator, x); - } - } + delete :: #match {} } diff --git a/core/container/iter.onyx b/core/container/iter.onyx index c5853d8d..e84d8ba4 100644 --- a/core/container/iter.onyx +++ b/core/container/iter.onyx @@ -479,9 +479,8 @@ generic_dynamic_array_as_iter :: (x: &[..] $T, $access: Code, $return_type: type current: u32; } - c := make(Context(T), allocator=context.temp_allocator); + c := new_temp(Context(T)); c.arr = x; - c.current = 0; next :: (use _: &Context($T), $access: Code) => { if current < arr.count { @@ -792,7 +791,7 @@ generator_no_copy :: (ctx: &$Ctx, gen: (&Ctx) -> ($T, bool), close: (&Ctx) -> vo close :: (use c: &Context($T)) { sync.mutex_destroy(&c.mutex); - delete(c); + cfree(c); } // This iterator's context is allocated from the heap because diff --git a/tests/aoc-2021/day12.onyx b/tests/aoc-2021/day12.onyx index 32faed1d..a525d855 100644 --- a/tests/aoc-2021/day12.onyx +++ b/tests/aoc-2021/day12.onyx @@ -41,7 +41,7 @@ main :: (args) => { node_stack << .{ "start", 0, false }; children_of :: (edges: &$T, name: str) -> Iterator(str) { - name_copy := make_temp(str); + name_copy := new_temp(str); *name_copy = name; return iter.concat( diff --git a/tests/aoc-2021/day18.onyx b/tests/aoc-2021/day18.onyx index cc308572..ca33d3ee 100644 --- a/tests/aoc-2021/day18.onyx +++ b/tests/aoc-2021/day18.onyx @@ -19,7 +19,7 @@ SnailNum :: struct { allocator: Allocator; make :: () => { - return make(SnailNum, SnailNum.allocator); + return new(SnailNum, SnailNum.allocator); } make_pair :: (left, right: u32) => { diff --git a/tests/utf8_test.onyx b/tests/utf8_test.onyx index bc1f6ed3..d6d2c51d 100644 --- a/tests/utf8_test.onyx +++ b/tests/utf8_test.onyx @@ -1,8 +1,12 @@ use core use core.encoding {utf8} +#inject runtime.vars.Enable_Heap_Debug :: true + main :: () { - output: dyn_str; + output := make(dyn_str); + defer delete(&output); + for i: 0x1F0A0 .. 0x1F0E0 { utf8.append_rune(&output, i); }