From 4372a1f56cafec74dfb69cd3cdda4f885b5c2cf3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 19 Nov 2024 16:41:35 -0800 Subject: [PATCH] Assert on OOM. --- src/bgfx.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/bgfx.cpp b/src/bgfx.cpp index 600cf8429..eb08cee43 100644 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -217,18 +217,30 @@ namespace bgfx } #endif // BGFX_CONFIG_MEMORY_TRACKING - return ::malloc(_size); + void* ptr = ::malloc(_size); + BX_ASSERT(NULL != ptr, "Out of memory!"); + + return ptr; } - return bx::alignedAlloc(this, _size, _align, bx::Location(_file, _line) ); + void* ptr = bx::alignedAlloc(this, _size, _align, bx::Location(_file, _line) ); + BX_ASSERT(NULL != ptr, "Out of memory!"); + + return ptr; } if (kNaturalAlignment >= _align) { - return ::realloc(_ptr, _size); + void* ptr = ::realloc(_ptr, _size); + BX_ASSERT(NULL != ptr, "Out of memory!"); + + return ptr; } - return bx::alignedRealloc(this, _ptr, _size, _align, bx::Location(_file, _line) ); + void* ptr = bx::alignedRealloc(this, _ptr, _size, _align, bx::Location(_file, _line) ); + BX_ASSERT(NULL != ptr, "Out of memory!"); + + return ptr; } void checkLeaks();