Skip to content

Commit

Permalink
Assert on OOM.
Browse files Browse the repository at this point in the history
  • Loading branch information
bkaradzic committed Nov 20, 2024
1 parent e9c9d71 commit 4372a1f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions src/bgfx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 4372a1f

Please sign in to comment.