[ODE] Memory allocation

Dominic Jackson dominic.jackson at kuju.com
Sun Oct 3 10:40:02 MST 2004


OK, thanks for the quick reply, however ...

I looked at doing this but am not convinced that calling dGeomDestroy is totally safe - surely the delete knows nothing about the inherited structure (with its additional size). The memory alloc / free functions we use involve knowing the size of object on delete, so maybe I do actually have to write specific destroy functions for sphere, box, etc ... ? ... or switch to a different allocator :-)

struct dxSphere : public dxGeom {
  dReal radius;		// sphere radius
  dxSphere (dSpaceID space, dReal _radius);
  void computeAABB();
};

void dGeomDestroy (dxGeom *g)
{
  dAASSERT (g);
  delete g;
}





-----Original Message-----
From: Arturo Colorado Garín [mailto:acolorado at telefonica.net] 
Sent: 02 October 2004 20:12
To: ODE (Mailing List)
Subject: Re: [ODE] Memory allocation

To free a body, call dBodyDestroy(). To free a sphere or any other geom,
call dGeomDestroy().

In general, when you're going to free an object look up the documentation to
see if there is a matching free function for that object subtype. If there
is not, use a more generic free function (for example, dGeomDestroy() for
any geom or dJointDestroy() for any joint).

--Arturo


----- Original Message ----- 
From: Dominic Jackson
To: ode at q12.org
Cc: Adam Croston
Sent: Saturday, October 02, 2004 8:20 PM
Subject: [ODE] Memory allocation



Hi,

I am using dBodyCreate as well as other allocation functions such as
dCreateSphere etc...  from the collision modules.

Some of these functions don't seem to have matching free functions - can
anyone tell me what the correct way is to delete things

I suspect I will have to write my own functions unless I have just missed
something
( presumably if I just use delete on a dxGeom, It wont know how much memory
to delete for specific cases such as Box, Sphere, CCylinder etc .. )

Can anyone help on this or am I going down the right track just writing my
own wrapper functions.

I did notice in the code there is a pragma for no-matching delete warnings -
so perhaps this is intentional and I have missed the point ?

Regards

Dominic Jackson

_______________________________________________
ODE mailing list
ODE at q12.org
http://q12.org/mailman/listinfo/ode

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________



More information about the ODE mailing list