[ODE] more memory management pickyness
Nate W
coding at natew.com
Sat Dec 22 17:20:01 2001
As Russ said, these aren't really leaks, but still... I just can't stand
it when things show up in the 'memory leak' report. :-) The previous
version of this didn't have the "if (classes)" check, so it would crash if
you hadn't actually created any geometry yet. It also didn't free the
_data members of the classs and colliders arrays.
void dCloseODE ()
{
if (classes)
{
for (int i = 0; i < classes->size (); i++)
{
dFree ((*classes)[i], sizeof (dxGeomClass));
}
}
dFree (classes->_data, sizeof (dxGeomClass*) * classes->_anum);
dFree (classes, sizeof(dArrayBase));
dFree (colliders->_data, sizeof (dColliderEntry) * classes->_anum);
dFree (colliders, sizeof(dArrayBase));
}
In order to get it to compile, I also had to make it a friend of class
dArray, like this:
extern "C" void dCloseODE ();
template <class T> class dArray : public dArrayBase
{
friend void dCloseODE ();
public:
etc, etc, etc...
Nate Waddoups
Redmond WA USA
http://www.natew.com