Precipitation destroySplash funniness
by Clint S. Brewer · in Torque Game Engine · 07/29/2006 (1:33 am) · 0 replies
The original gangster function
what I think it should be
was getting some heap corruption from somebody poking this stuff.
I think that even if the drop is the splash head, you still want to make sure that drop->nextSplashDrop and drop->PrevSplashDrop _if_ they exist get cleaned up before getting rid of drop itself.
granted prevSplashDrop should never exist for mSplashHead, but I think next might actually be around.
after making this change, my heap corruption went away.
-c
void Precipitation::destroySplash(Raindrop *drop)
{
PROFILE_START(PrecipDestroySplash);
if (drop == mSplashHead)
{
mSplashHead = NULL;
}
else
{
if (drop->nextSplashDrop)
drop->nextSplashDrop->prevSplashDrop = drop->prevSplashDrop;
if (drop->prevSplashDrop)
drop->prevSplashDrop->nextSplashDrop = drop->nextSplashDrop;
drop->nextSplashDrop = NULL;
drop->prevSplashDrop = NULL;
}
PROFILE_END();
}what I think it should be
void Precipitation::destroySplash(Raindrop *drop)
{
PROFILE_START(PrecipDestroySplash);
if (drop->nextSplashDrop)
drop->nextSplashDrop->prevSplashDrop = drop->prevSplashDrop;
if (drop->prevSplashDrop)
drop->prevSplashDrop->nextSplashDrop = drop->nextSplashDrop;
drop->nextSplashDrop = NULL;
drop->prevSplashDrop = NULL;
if (drop == mSplashHead)
{
mSplashHead = NULL;
}
PROFILE_END();
}was getting some heap corruption from somebody poking this stuff.
I think that even if the drop is the splash head, you still want to make sure that drop->nextSplashDrop and drop->PrevSplashDrop _if_ they exist get cleaned up before getting rid of drop itself.
granted prevSplashDrop should never exist for mSplashHead, but I think next might actually be around.
after making this change, my heap corruption went away.
-c
About the author