Modify user values in mujoco to allow users to provide cleanup functions to avoid memory leaks.
For the MJCF -> USD plugin, and I suspect other usecases for user values, it's necessary to give ownership of the object to Mujoco. However since they get type erased, we can't clean up the data automatically for the user. Instead this allows c++ clients to provide a cleanup function with their data. PiperOrigin-RevId: 756832010 Change-Id: I80b8e7822e1a0e399a0d19dcaa57ee69b3ccc16a
This commit is contained in:
committed by
Copybara-Service
parent
baf84265b8
commit
924ee3070a
@@ -3732,6 +3732,9 @@ const char* mjs_resolveOrientation(double quat[4], mjtByte degree, const char* s
|
||||
const mjsOrientation* orientation);
|
||||
mjsFrame* mjs_bodyToFrame(mjsBody** body);
|
||||
void mjs_setUserValue(mjsElement* element, const char* key, const void* data);
|
||||
void mjs_setUserValueWithCleanup(mjsElement* element, const char* key,
|
||||
const void* data,
|
||||
void (*cleanup)(const void*));
|
||||
const void* mjs_getUserValue(mjsElement* element, const char* key);
|
||||
void mjs_deleteUserValue(mjsElement* element, const char* key);
|
||||
void mjs_defaultSpec(mjSpec* spec);
|
||||
|
||||
Reference in New Issue
Block a user