diff --git a/src/platform/platform.cpp b/src/platform/platform.cpp index 934220c..a080982 100644 --- a/src/platform/platform.cpp +++ b/src/platform/platform.cpp @@ -684,20 +684,21 @@ void DebugPrint(const char *fmt, ...) { //----------------------------------------------------------------------------- struct MimallocHeap { - mi_heap_t *heap = mi_heap_new(); - - MimallocHeap() { - ssassert(heap != NULL, "out of memory"); - } + mi_heap_t *heap = NULL; ~MimallocHeap() { - mi_heap_destroy(heap); + if(heap != NULL) + mi_heap_destroy(heap); } }; static thread_local MimallocHeap TempArena; void *AllocTemporary(size_t size) { + if(TempArena.heap == NULL) { + TempArena.heap = mi_heap_new(); + ssassert(TempArena.heap != NULL, "out of memory"); + } void *ptr = mi_heap_zalloc(TempArena.heap, size); ssassert(ptr != NULL, "out of memory"); return ptr;