Add mj_stackAllocInt to get correct size for allocating ints on mjData stack. Reducing stack memory usage by 10% - 15%.

PiperOrigin-RevId: 517672195
Change-Id: Ie14e6c9c99e8b9e1c5d3686b77631f2df0651c67
This commit is contained in:
Kyle Bayes
2023-03-18 13:03:11 -07:00
committed by Copybara-Service
parent fae5e822c0
commit 8696247f9d
17 changed files with 103 additions and 48 deletions
+3 -3
View File
@@ -418,8 +418,8 @@ void mju_sqrMatTDSparse(mjtNum* res, const mjtNum* mat, const mjtNum* matT,
int* res_rownnz, int* res_rowadr, int* res_colind,
const int* rownnz, const int* rowadr,
const int* colind, const int* rowsuper,
const int* rownnzT, const int* rowadrT,
const int* colindT, const int* rowsuperT,
const int* rownnzT, const int* rowadrT,
const int* colindT, const int* rowsuperT,
mjData* d) {
// allocate space for accumulation buffer and matT
mjMARKSTACK;
@@ -434,7 +434,7 @@ void mju_sqrMatTDSparse(mjtNum* res, const mjtNum* mat, const mjtNum* matT,
// these mark the currently set columns in the dense row buffer,
// used for when creating the resulting sparse row
int* markers = (int*) mj_stackAlloc(d, nc);
int* markers = mj_stackAllocInt(d, nc);
for (int i=0; i<nc; i++) {
int* cols = res_colind+res_rowadr[i];