From bff3426d254bf728b330c6f93fac97339cc41c67 Mon Sep 17 00:00:00 2001 From: Andrea Piseri Date: Sun, 6 Mar 2022 10:21:46 +0100 Subject: [PATCH] Fix leak in `core:container/bit_array` calling `clear` on a `bit_array` no longer leaks the previous allocation, instead it sets all bits to `false` preserving the same backing dynamic array. --- core/container/bit_array/bit_array.odin | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/container/bit_array/bit_array.odin b/core/container/bit_array/bit_array.odin index 5eebe1bcb..0016ca105 100644 --- a/core/container/bit_array/bit_array.odin +++ b/core/container/bit_array/bit_array.odin @@ -1,6 +1,7 @@ package dynamic_bit_array import "core:intrinsics" +import "core:mem" /* Note that these constants are dependent on the backing being a u64. @@ -206,7 +207,7 @@ create :: proc(max_index: int, min_index := 0, allocator := context.allocator) - */ clear :: proc(ba: ^Bit_Array) { if ba == nil { return } - ba.bits = {} + mem.zero_slice(ba.bits[:]) } /*