heap freeing fixes; added optional allocator to format_va
authorBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 12 Sep 2022 13:44:42 +0000 (08:44 -0500)
committerBrendan Hansen <brendan.f.hansen@gmail.com>
Mon, 12 Sep 2022 13:44:42 +0000 (08:44 -0500)
core/alloc/heap.onyx
core/conv.onyx

index d01f38f2b7bcaccd029778094babcbb811bb5d4e..fa75c232b5a62a8a6dbb603285bcf051f68a40fd 100644 (file)
@@ -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;
index 67f3e3b38a820158af1dad0773869eaafe0dfffb..81c5e95ca6941165eac494b3322e76901af936f9 100644 (file)
@@ -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 }