[ODE] Fix leaking of s_cachedPosR in collision_kernel.cpp
Jon Watte (ODE)
hplus-ode at mindcontrol.org
Sat Jun 17 22:55:35 MST 2006
I added this patch to patch tracker:
When using leak checking allocators, the cached posR
inside collision_kernel.cpp gets reported. This patch
makes sure it gets disposed before the Windows leak
checker finds it, enabling a clean test run (at least
in my test code).
Cheers,
/ h+
--- ode/src/collision_kernel.cpp (revision 976)
+++ ode/src/collision_kernel.cpp (working copy)
@@ -50,6 +50,20 @@
// Allocate and free posr - we cache a single posr to
avoid thrashing
static dxPosR* s_cachedPosR = 0;
+namespace {
+ class DisposeCachedPosr {
+ public:
+ ~DisposeCachedPosr() {
+ if (s_cachedPosR) {
+ dFree(s_cachedPosR, sizeof(dxPosR));
+ s_cachedPosR = 0;
+ }
+ }
+ };
+
+ DisposeCachedPosr finalDispose;
+}
+
dxPosR* dAllocPosr()
{
dxPosR* retPosR;
More information about the ODE
mailing list