Improve error message when requested stack allocation is larger than 2^64 bytes.

PiperOrigin-RevId: 677851110
Change-Id: Iaef92f7f48f41f3a4bfaae9c517ff6664afed039
This commit is contained in:
Yuval Tassa
2024-09-23 10:33:41 -07:00
committed by Copybara-Service
parent 76b48b8e61
commit 84e0e2839d
+2 -2
View File
@@ -1697,7 +1697,7 @@ void* mj_stackAllocByte(mjData* d, size_t bytes, size_t alignment) {
// allocate mjtNums on the stack
mjtNum* mj_stackAllocNum(mjData* d, size_t size) {
if (mjUNLIKELY(size >= SIZE_MAX / sizeof(mjtNum))) {
mjERROR("requested size is too large.");
mjERROR("requested size is too large (more than 2^64 bytes).");
}
return (mjtNum*) stackalloc(d, size * sizeof(mjtNum), _Alignof(mjtNum));
}
@@ -1707,7 +1707,7 @@ mjtNum* mj_stackAllocNum(mjData* d, size_t size) {
// allocate ints on the stack
int* mj_stackAllocInt(mjData* d, size_t size) {
if (mjUNLIKELY(size >= SIZE_MAX / sizeof(int))) {
mjERROR("requested size is too large.");
mjERROR("requested size is too large (more than 2^64 bytes).");
}
return (int*) stackalloc(d, size * sizeof(int), _Alignof(int));
}