- fixed memory leak: The sector links for dynamic lights were never freed.

This commit is contained in:
Christoph Oelckers 2014-09-21 12:40:08 +02:00
parent 7359631a43
commit b2cf7d6512

View file

@ -411,7 +411,6 @@ size_t ADynamicLight::PointerSubstitution (DObject *old, DObject *notOld)
// nodes that will get linked in later. Returns a pointer to the new node. // nodes that will get linked in later. Returns a pointer to the new node.
// //
//============================================================================= //=============================================================================
static FreeList<FLightNode> freelist;
FLightNode * AddLightNode(FLightNode ** thread, void * linkto, ADynamicLight * light, FLightNode *& nextnode) FLightNode * AddLightNode(FLightNode ** thread, void * linkto, ADynamicLight * light, FLightNode *& nextnode)
{ {
@ -431,7 +430,7 @@ FLightNode * AddLightNode(FLightNode ** thread, void * linkto, ADynamicLight * l
// Couldn't find an existing node for this sector. Add one at the head // Couldn't find an existing node for this sector. Add one at the head
// of the list. // of the list.
node = freelist.GetNew(); node = new FLightNode;
node->targ = linkto; node->targ = linkto;
node->lightsource = light; node->lightsource = light;
@ -474,7 +473,7 @@ static FLightNode * DeleteLightNode(FLightNode * node)
// Return this node to the freelist // Return this node to the freelist
tn=node->nextTarget; tn=node->nextTarget;
freelist.Release(node); delete node;
return(tn); return(tn);
} }
return(NULL); return(NULL);
@ -661,6 +660,7 @@ void ADynamicLight::UnlinkLight ()
} }
while (touching_sides) touching_sides = DeleteLightNode(touching_sides); while (touching_sides) touching_sides = DeleteLightNode(touching_sides);
while (touching_subsectors) touching_subsectors = DeleteLightNode(touching_subsectors); while (touching_subsectors) touching_subsectors = DeleteLightNode(touching_subsectors);
while (touching_sector) touching_sector = DeleteLightNode(touching_sector);
} }
void ADynamicLight::Destroy() void ADynamicLight::Destroy()
@ -765,3 +765,4 @@ CCMD(listsublights)
} }
} }