[ODE] Worst Case Scenario - State save and restore

ACOLORADO at telefonica.net ACOLORADO at telefonica.net
Tue Feb 8 14:38:43 MST 2005


> One final thing, what happens if you point the following two 
> functions 
> to user space and then save the contents?:
> void dJointSetData (dJointID, void *data);
> void  dBodySetData (dBodyID, void *data);

You can save the pointer and restore it as long as you don't destroy 
the data that was pointed by this pointer between calls to SaveState() 
and its matching RestoreState().

But if you intend to RestoreState() after, for example, closing your 
application and relaunching it, this will not work at all for obvious 
reasons: if that data is created again, it will be at another memory 
location so the pointer you saved is now completly invalid. To achieve 
this you must save the data that is pointed by the pointer, not the 
pointer itself (NOTE: your SaveState() and RestoreState() functions 
then must know the type of that data -type of the structure, object or 
whatever you use- or at least its size in bytes).

Hope this helps,

--Arturo Colorado.




More information about the ODE mailing list