From: Brendan Hansen Date: Mon, 12 Sep 2022 13:44:42 +0000 (-0500) Subject: heap freeing fixes; added optional allocator to format_va X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=a0a985a264cb934c5fb4e302b73f2c06577ff699;p=onyx.git heap freeing fixes; added optional allocator to format_va --- diff --git a/core/alloc/heap.onyx b/core/alloc/heap.onyx index d01f38f2..fa75c232 100644 --- a/core/alloc/heap.onyx +++ b/core/alloc/heap.onyx @@ -178,6 +178,11 @@ get_freed_size :: () => { #if Enable_Debug { // assert(hb_ptr.size & Allocated_Flag == Allocated_Flag, "Corrupted heap on free. This could be due to a double free, or using memory past were you allocated it."); + if cast(uintptr) hb_ptr < cast(uintptr) __heap_start { + log("FREEING STATIC DATA"); + return; + } + if hb_ptr.size & Allocated_Flag != Allocated_Flag { log("INVALID DOUBLE FREE"); return; diff --git a/core/conv.onyx b/core/conv.onyx index 67f3e3b3..81c5e95c 100644 --- a/core/conv.onyx +++ b/core/conv.onyx @@ -365,9 +365,9 @@ format_va :: #match {} out := format_va(*buffer, format, va, flush); buffer.count = out.count; } -#match format_va (format: [] u8, va: [] any) -> str { +#match format_va (format: [] u8, va: [] any, allocator := context.allocator) -> str { buffer : [256] u8; - out := make([..] u8); + out := make([..] u8, allocator=allocator); output := Format_Output.{ ~~buffer, 0, buffer.count, flush=.{ ^out, flush_to_dynstr }