From 13f1cdca7bdac4b06b4d521e3ea2b371663387ff Mon Sep 17 00:00:00 2001 From: Jarred Sumner Date: Mon, 14 Mar 2022 05:39:22 -0700 Subject: [PATCH] add another assertion --- src/memory_allocator.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/memory_allocator.zig b/src/memory_allocator.zig index 3b51888957..1cc6f9cafc 100644 --- a/src/memory_allocator.zig +++ b/src/memory_allocator.zig @@ -141,7 +141,14 @@ const CAllocator = struct { ) void { _ = buf_align; _ = return_address; - mimalloc.mi_free(buf.ptr); + // mi_free_size internally just asserts the size + // so it's faster if we don't pass that value through + // but its good to have that assertion + if (comptime Environment.allow_assert) { + mimalloc.mi_free_size(buf.ptr, buf.len); + } else { + mimalloc.mi_free(buf.ptr); + } } };