From 4930a9c1a49ea2e0d7c286812f3e64cc08e1eb23 Mon Sep 17 00:00:00 2001 From: gingerBill Date: Tue, 15 Sep 2020 11:51:38 +0100 Subject: [PATCH] Add mem.clone_slice --- core/mem/mem.odin | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/mem/mem.odin b/core/mem/mem.odin index 55b9afe2e..80055b4b4 100644 --- a/core/mem/mem.odin +++ b/core/mem/mem.odin @@ -279,3 +279,11 @@ calc_padding_with_header :: proc(ptr: uintptr, align: uintptr, header_size: int) return int(padding); } + + + +clone_slice :: proc(slice: $T/[]$E, allocator := context.allocator, loc := #caller_location) -> T { + new_slice := make(T, len(slice), allocator, loc); + copy(new_slice, slice); + return new_slice; +}