globle void FlushMultifields( void *theEnv) { struct multifield *theSegment, *nextPtr, *lastPtr = NULL; unsigned long newSize; theSegment = UtilityData(theEnv)->CurrentGarbageFrame->ListOfMultifields; while (theSegment != NULL) { nextPtr = theSegment->next; if (theSegment->busyCount == 0) { if (theSegment->multifieldLength == 0) newSize = 1; else newSize = theSegment->multifieldLength; rtn_var_struct(theEnv,multifield,sizeof(struct field) * (newSize - 1),theSegment); if (lastPtr == NULL) UtilityData(theEnv)->CurrentGarbageFrame->ListOfMultifields = nextPtr; else lastPtr->next = nextPtr; /*=================================================*/ /* If the multifield deleted was the last in the */ /* list, update the pointer to the last multifield */ /* to the prior multifield. */ /*=================================================*/ if (nextPtr == NULL) { UtilityData(theEnv)->CurrentGarbageFrame->LastMultifield = lastPtr; } } else { lastPtr = theSegment; } theSegment = nextPtr; } }
globle void FlushMultifields( void *theEnv) { struct multifield *theSegment, *nextPtr, *lastPtr = NULL; unsigned long newSize; theSegment = MultifieldData(theEnv)->ListOfMultifields; while (theSegment != NULL) { nextPtr = theSegment->next; if ((theSegment->depth > EvaluationData(theEnv)->CurrentEvaluationDepth) && (theSegment->busyCount == 0)) { UtilityData(theEnv)->EphemeralItemCount--; UtilityData(theEnv)->EphemeralItemSize -= sizeof(struct multifield) + (sizeof(struct field) * theSegment->multifieldLength); if (theSegment->multifieldLength == 0) newSize = 1; else newSize = theSegment->multifieldLength; rtn_var_struct(theEnv,multifield,sizeof(struct field) * (newSize - 1),theSegment); if (lastPtr == NULL) MultifieldData(theEnv)->ListOfMultifields = nextPtr; else lastPtr->next = nextPtr; } else { lastPtr = theSegment; } theSegment = nextPtr; } }
globle void ReturnMultifield( void *theEnv, struct multifield *theSegment) { unsigned long newSize; if (theSegment == NULL) return; if (theSegment->multifieldLength == 0) newSize = 1; else newSize = theSegment->multifieldLength; rtn_var_struct(theEnv,multifield,sizeof(struct field) * (newSize - 1),theSegment); }
globle void DestroyPartialMatch( void *theEnv, struct partialMatch *waste) { /*======================================================*/ /* If we're dealing with an alpha memory partial match, */ /* then return the multifield markers associated with */ /* the partial match (if any) along with the alphaMatch */ /* data structure. */ /*======================================================*/ if (waste->betaMemory == FALSE) { if (waste->binds[0].gm.theMatch->markers != NULL) { ReturnMarkers(theEnv,waste->binds[0].gm.theMatch->markers); } rm(theEnv,waste->binds[0].gm.theMatch,(int) sizeof(struct alphaMatch)); } /*================================================*/ /* Remove the alpha match used to represent a not */ /* CE match in a beta memory partial match. */ /*================================================*/ if ((waste->notOriginf) && (waste->counterf == FALSE)) { if (waste->binds[waste->bcount - 1].gm.theMatch != NULL) { rtn_struct(theEnv,alphaMatch, waste->binds[waste->bcount - 1].gm.theMatch); } } /*=================================================*/ /* Remove any links between the partial match and */ /* a data entity that were created with the use of */ /* the logical CE. */ /*=================================================*/ #if LOGICAL_DEPENDENCIES if (waste->dependentsf) DestroyPMDependencies(theEnv,waste); #endif /*======================================================*/ /* Return the partial match to the pool of free memory. */ /*======================================================*/ rtn_var_struct(theEnv,partialMatch,(int) sizeof(struct genericMatch *) * (waste->bcount + waste->activationf + waste->dependentsf - 1), waste); }
globle void ReturnPartialMatch( void *theEnv, struct partialMatch *waste) { /*==============================================*/ /* If the partial match is in use, then put it */ /* on a garbage list to be processed later when */ /* the partial match is not in use. */ /*==============================================*/ if (waste->busy) { waste->next = EngineData(theEnv)->GarbagePartialMatches; EngineData(theEnv)->GarbagePartialMatches = waste; return; } /*======================================================*/ /* If we're dealing with an alpha memory partial match, */ /* then return the multifield markers associated with */ /* the partial match (if any) along with the alphaMatch */ /* data structure. */ /*======================================================*/ if (waste->betaMemory == FALSE) { if (waste->binds[0].gm.theMatch->markers != NULL) { ReturnMarkers(theEnv,waste->binds[0].gm.theMatch->markers); } rm(theEnv,waste->binds[0].gm.theMatch,(int) sizeof(struct alphaMatch)); } /*=================================================*/ /* Remove any links between the partial match and */ /* a data entity that were created with the use of */ /* the logical CE. */ /*=================================================*/ #if LOGICAL_DEPENDENCIES if (waste->dependentsf) RemovePMDependencies(theEnv,waste); #endif /*======================================================*/ /* Return the partial match to the pool of free memory. */ /*======================================================*/ rtn_var_struct(theEnv,partialMatch,(int) sizeof(struct genericMatch *) * (waste->bcount + waste->activationf + waste->dependentsf - 1), waste); }