globle void FlushGarbagePartialMatches( void *theEnv) { struct partialMatch *pmPtr; struct alphaMatch *amPtr; /*===================================================*/ /* Return the garbage partial matches collected from */ /* the alpha memories of the pattern networks. */ /*===================================================*/ while (EngineData(theEnv)->GarbageAlphaMatches != NULL) { amPtr = EngineData(theEnv)->GarbageAlphaMatches->next; rtn_struct(theEnv,alphaMatch,EngineData(theEnv)->GarbageAlphaMatches); EngineData(theEnv)->GarbageAlphaMatches = amPtr; } /*==============================================*/ /* Return the garbage partial matches collected */ /* from the beta memories of the join networks. */ /*==============================================*/ while (EngineData(theEnv)->GarbagePartialMatches != NULL) { /*=====================================================*/ /* Remember the next garbage partial match to process. */ /*=====================================================*/ pmPtr = EngineData(theEnv)->GarbagePartialMatches->next; /*=======================================================*/ /* If a "pseudo" data entity was created for the partial */ /* match (i.e. a not CE was satisfied), then dispose of */ /* the pseudo data entity. */ /*=======================================================*/ if ((EngineData(theEnv)->GarbagePartialMatches->notOriginf) && (EngineData(theEnv)->GarbagePartialMatches->counterf == FALSE)) { if (EngineData(theEnv)->GarbagePartialMatches->binds[EngineData(theEnv)->GarbagePartialMatches->bcount - 1].gm.theMatch != NULL) { rtn_struct(theEnv,alphaMatch, EngineData(theEnv)->GarbagePartialMatches->binds[EngineData(theEnv)->GarbagePartialMatches->bcount - 1].gm.theMatch); } } /*============================================*/ /* Dispose of the garbage partial match being */ /* examined and move on to the next one. */ /*============================================*/ EngineData(theEnv)->GarbagePartialMatches->busy = FALSE; ReturnPartialMatch(theEnv,EngineData(theEnv)->GarbagePartialMatches); EngineData(theEnv)->GarbagePartialMatches = pmPtr; } }
static void DeletePartialMatches( void *theEnv, struct partialMatch *listOfPMs, int betaDelete) { struct partialMatch *nextPM; while (listOfPMs != NULL) { /*============================================*/ /* Remember the next partial match to delete. */ /*============================================*/ nextPM = listOfPMs->next; /*================================================*/ /* Remove the links between the partial match and */ /* any data entities that it is attached to as a */ /* result of a logical CE. */ /*================================================*/ #if LOGICAL_DEPENDENCIES if (listOfPMs->dependentsf) RemoveLogicalSupport(theEnv,listOfPMs); #endif /*==========================================================*/ /* If the partial match is being deleted from a beta memory */ /* and the partial match isn't associated with a satisfied */ /* not CE, then it can be immediately returned to the pool */ /* of free memory. Otherwise, it's could be in use (either */ /* to retrieve variables from the LHS or by the activation */ /* of the rule). Since a not CE creates a "pseudo" data */ /* entity, the beta partial match which stores this pseudo */ /* data entity can not be deleted immediately (for the same */ /* reason an alpha memory partial match can't be deleted */ /* immediately). */ /*==========================================================*/ if (betaDelete && ((listOfPMs->notOriginf == FALSE) || (listOfPMs->counterf))) { ReturnPartialMatch(theEnv,listOfPMs); } else { listOfPMs->next = EngineData(theEnv)->GarbagePartialMatches; EngineData(theEnv)->GarbagePartialMatches = listOfPMs; } /*====================================*/ /* Move on to the next partial match. */ /*====================================*/ listOfPMs = nextPM; } }
globle void FlushAlphaBetaMemory( struct partialMatch *pfl) { struct partialMatch *pfltemp; while (pfl != NULL) { pfltemp = pfl->next; if (((pfl->notOriginf) && (pfl->counterf == FALSE)) || (pfl->betaMemory == FALSE)) { pfl->next = GarbagePartialMatches; GarbagePartialMatches = pfl; } else { ReturnPartialMatch(pfl); } pfl = pfltemp; } }