From 5ba4d5849716389d7ac7e0a2095435c521e06007 Mon Sep 17 00:00:00 2001 From: Levi Burner Date: Tue, 26 Nov 2024 13:16:05 -0500 Subject: [PATCH] replace array on stack with std::vector --- python/mujoco/rollout.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/python/mujoco/rollout.cc b/python/mujoco/rollout.cc index a738c87a..838ecc5b 100644 --- a/python/mujoco/rollout.cc +++ b/python/mujoco/rollout.cc @@ -54,7 +54,7 @@ Roll out open-loop trajectories from initial states, get resulting states and se // C-style rollout function, assumes all arguments are valid // all input fields of d are initialised, contents at call time do not matter // after returning, d will contain the last step of the last rollout -void _unsafe_rollout(const mjModel** m, mjData* d, int nroll, int nstep, unsigned int control_spec, +void _unsafe_rollout(std::vector& m, mjData* d, int nroll, int nstep, unsigned int control_spec, const mjtNum* state0, const mjtNum* warmstart0, const mjtNum* control, mjtNum* state, mjtNum* sensordata) { // sizes @@ -198,7 +198,8 @@ PYBIND11_MODULE(_rollout, pymodule) { ) { // get raw pointers int nroll = state0.shape(0); - const raw::MjModel* model_ptrs[nroll]; + std::vector model_ptrs; + model_ptrs.reserve(nroll); for (int r = 0; r < nroll; r++) { model_ptrs[r] = m[r].cast()->get(); }