From a3b009f119ce505dc7eded7a8298164d623c0f1a Mon Sep 17 00:00:00 2001 From: ccremers Date: Sat, 8 Oct 2005 19:53:10 +0000 Subject: [PATCH] - The state of sys->variables was not maintained correctly, because terms were destroyed before it could be tested whether they were in sys->variables. Thus, garbage was left in sys->variables. This has gone undetected because it was never really used. Hmpf. --- src/system.c | 52 ++++++++++++++++++++++++++++------------------------ 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/src/system.c b/src/system.c index de0bb3c..1927451 100644 --- a/src/system.c +++ b/src/system.c @@ -991,6 +991,34 @@ roleInstanceDestroy (const System sys) roledefDestroy (myrun.start); // Destroy artefacts + // + // sys->variables might contain locals from the run: remove them + { + Termlist tl; + + tl = sys->variables; + while (tl != NULL) + { + Term t; + + t = tl->term; + if (realTermLeaf (t) && TermRunid (t) == runid) + { + Termlist tlnext; + + tlnext = tl->next; + // remove from list; return pointer to head + sys->variables = termlistDelTerm (tl); + tl = tlnext; + } + else + { + // proceed + tl = tl->next; + } + } + } + /* * Arachne does real-time reduction of memory, POR does not * Artefact removal can only be done if knowledge sets are empty, as with Arachne @@ -1026,30 +1054,6 @@ roleInstanceDestroy (const System sys) } termlistDelete (myrun.substitutions); - // sys->variables might contain locals from the run: remove them - { - Termlist tl; - - tl = sys->variables; - while (tl != NULL) - { - Term t; - - t = tl->term; - if (realTermLeaf (t) && TermRunid (t) == runid) - { - // remove from list; return pointer to head - sys->variables = termlistDelTerm (tl); - tl = sys->variables; - } - else - { - // proceed - tl = tl->next; - } - } - } - // remove lists termlistDelete (myrun.artefacts); termlistDelete (myrun.locals);