From: Brendan Hansen Date: Fri, 10 Mar 2023 16:15:16 +0000 (-0600) Subject: cleanup: deleting slices and arena resize X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=c0e18f34c7397d144fd311a43ccd02d3337dd582;p=onyx.git cleanup: deleting slices and arena resize --- diff --git a/core/alloc/arena.onyx b/core/alloc/arena.onyx index d9ef2a47..0fce91fc 100644 --- a/core/alloc/arena.onyx +++ b/core/alloc/arena.onyx @@ -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. diff --git a/core/builtin.onyx b/core/builtin.onyx index 332ac85b..97544d49 100644 --- a/core/builtin.onyx +++ b/core/builtin.onyx @@ -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); - } } diff --git a/core/memory/memory.onyx b/core/memory/memory.onyx index e353e64e..9f31f13d 100644 --- a/core/memory/memory.onyx +++ b/core/memory/memory.onyx @@ -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); }