changed: `make` and `delete` no longer have pointer implementations
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 9 Mar 2023 00:54:17 +0000 (18:54 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Thu, 9 Mar 2023 00:54:17 +0000 (18:54 -0600)
core/builtin.onyx
core/container/iter.onyx
tests/aoc-2021/day12.onyx
tests/aoc-2021/day18.onyx
tests/utf8_test.onyx

index af99c4ca7b80bcedc25b0438b61c1c19f369564a..aa5402c85bc845c7ef06f1882d8a250c8cc17815 100644 (file)
@@ -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 {}
 }
 
 
index c5853d8d097069a8aa7ba4a2fd69a3eb32bd3d5d..e84d8ba421a43e8cf337307bec869859dd7a8bec 100644 (file)
@@ -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
index 32faed1d7a8c07c29bde9562e5dfc089d5b8586c..a525d8552d97e521c3f4b43f1da329a1b988b9bf 100644 (file)
@@ -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(
index cc308572091bed7338450b2f4b85c2a11661dfb5..ca33d3ee27f76d8a9b81f9b59847c2554759f48c 100644 (file)
@@ -19,7 +19,7 @@ SnailNum :: struct {
     allocator: Allocator;
 
     make :: () => {
-        return make(SnailNum, SnailNum.allocator);
+        return new(SnailNum, SnailNum.allocator);
     }
 
     make_pair :: (left, right: u32) => {
index bc1f6ed33738561d4c52d54f4da4c5e3c84cc159..d6d2c51d3163c928b51645105e568cc985f67a25 100644 (file)
@@ -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);
     }