Stop leaking function damage expressions.

- Function damage expressions parsed from DECORATE are now stored in a
  single array and deleted at the end of FinishThingdef().
This commit is contained in:
Randy Heit 2013-07-25 21:42:30 -05:00
parent e3e32d7cca
commit 070c0a9e30
3 changed files with 16 additions and 2 deletions

View File

@ -66,6 +66,8 @@
#include "vmbuilder.h"
#include "stats.h"
TDeletingArray<class FxExpression *> ActorDamageFuncs;
// EXTERNAL FUNCTION PROTOTYPES --------------------------------------------
void InitThingdef();
void ParseDecorate (FScanner &sc);
@ -351,8 +353,8 @@ static void FinishThingdef()
if (def->Damage != NULL)
{
FxDamageValue *dmg = (FxDamageValue *)ActorDamageFuncs[(uintptr_t)def->Damage - 1];
VMScriptFunction *sfunc;
FxDamageValue *dmg = (FxDamageValue *)def->Damage;
sfunc = dmg->GetFunction();
if (sfunc == NULL)
{
@ -389,6 +391,9 @@ static void FinishThingdef()
I_Error("%d errors during actor postprocessing", errorcount);
}
ActorDamageFuncs.DeleteAndClear();
StateTempCalls.DeleteAndClear();
// Since these are defined in DECORATE now the table has to be initialized here.
for(int i = 0; i < 31; i++)
{
@ -415,6 +420,7 @@ void LoadActors ()
timer.Reset(); timer.Clock();
StateParams.Clear();
ActorDamageFuncs.Clear();
GlobalSymbols.ReleaseSymbols();
FScriptPosition::ResetErrorCounter();
InitThingdef();

View File

@ -154,6 +154,7 @@ public:
extern FStateExpressions StateParams;
extern TDeletingArray<class FxExpression *> ActorDamageFuncs;
//==========================================================================
//

View File

@ -544,7 +544,14 @@ DEFINE_PROPERTY(damage, X, Actor)
// Store this expression here for now. It will be converted to a function
// later once all actors have been processed.
defaults->Damage = (VMFunction *)id;
if (id == NULL)
{
defaults->Damage = NULL;
}
else
{
defaults->Damage = (VMFunction *)(uintptr_t)(ActorDamageFuncs.Push(id) + 1);
}
}
//==========================================================================