cleanup: deleting slices and arena resize
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 10 Mar 2023 16:15:16 +0000 (10:15 -0600)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Fri, 10 Mar 2023 16:15:16 +0000 (10:15 -0600)
core/alloc/arena.onyx
core/builtin.onyx
core/memory/memory.onyx

index d9ef2a473196431bdd8da0e5468930dfa9d8a195..0fce91fc81ff175df6a1e0cf94ce4c558cda8990 100644 (file)
@@ -74,12 +74,8 @@ arena_alloc_proc :: (data: rawptr, aa: AllocationAction, size: u32, align: u32,
     }
 
     if aa == .Resize {
-        // An allocation of this size does not fit into a single arena.
-        if size > alloc_arena.arena_size - sizeof rawptr {
-            return null;
-        }
-
         newptr := arena_alloc_proc(data, .Alloc, size, align, oldptr);
+        if newptr == null do return null;
 
         // This is incorrect, but because there is not an "old size",
         // this is the best possible.
index 332ac85b109568f91c881677ce97a5d46375b092..97544d49d858ea8e22d11203ecf37169e6e8d77d 100644 (file)
@@ -361,18 +361,6 @@ cfree   :: (ptr: rawptr)            => raw_free(context.allocator, ptr);
         T.destroy(x_);
         cfree(x_);
     }
-
-    #local
-    IsNotDoublePointer :: interface (t: $T) {
-        #not **t;
-    }
-
-    #overload #order 1001
-    delete :: macro (x: &$T/core.intrinsics.types.type_is_simple)
-        where IsNotDoublePointer(&T)
-    {
-        cfree(x);
-    }
 }
 
 
index e353e64e5c7a2aa8898601dc90a186534ad5bbe3..9f31f13d907e91d0fba70ef5a8113469fccaf60c 100644 (file)
@@ -78,7 +78,7 @@ builtin.__make_overload :: macro (_: &[] $T, count: u32, allocator := context.al
 //
 // Allows for delete(&sl);
 #overload
-builtin.delete :: macro (x: &[] $T) {
-    #this_package.free_slice(x);
+builtin.delete :: macro (x: &[] $T, allocator := context.allocator) {
+    #this_package.free_slice(x, allocator);
 }