static void ClearBload( void *theEnv) { long i; size_t space; /*=============================================*/ /* Decrement in use counters for atomic values */ /* contained in the construct headers. */ /*=============================================*/ for (i = 0; i < DeffactsBinaryData(theEnv)->NumberOfDeffacts; i++) { UnmarkConstructHeader(theEnv,&DeffactsBinaryData(theEnv)->DeffactsArray[i].header); } /*=============================================================*/ /* Deallocate the space used for the deffacts data structures. */ /*=============================================================*/ space = DeffactsBinaryData(theEnv)->NumberOfDeffacts * sizeof(struct deffacts); if (space != 0) genfree(theEnv,(void *) DeffactsBinaryData(theEnv)->DeffactsArray,space); DeffactsBinaryData(theEnv)->NumberOfDeffacts = 0; /*====================================================================*/ /* Deallocate the space used for the deffacts module data structures. */ /*====================================================================*/ space = DeffactsBinaryData(theEnv)->NumberOfDeffactsModules * sizeof(struct deffactsModule); if (space != 0) genfree(theEnv,(void *) DeffactsBinaryData(theEnv)->ModuleArray,space); DeffactsBinaryData(theEnv)->NumberOfDeffactsModules = 0; }
static void ClearBload() { long i; unsigned long space; /*=======================================================*/ /* Decrement in use counters for atomic values contained */ /* in the construct headers. Also decrement data */ /* structures used to store the defglobal's value. */ /*=======================================================*/ for (i = 0; i < NumberOfDefglobals; i++) { UnmarkConstructHeader(&DefglobalArray[i].header); ValueDeinstall(&(DefglobalArray[i].current)); if (DefglobalArray[i].current.type == MULTIFIELD) { ReturnMultifield((struct multifield *) DefglobalArray[i].current.value); } } /*==============================================================*/ /* Deallocate the space used for the defglobal data structures. */ /*==============================================================*/ space = NumberOfDefglobals * sizeof(struct defglobal); if (space != 0) genlongfree((void *) DefglobalArray,space); /*=====================================================================*/ /* Deallocate the space used for the defglobal module data structures. */ /*=====================================================================*/ space = NumberOfDefglobalModules * sizeof(struct defglobalModule); if (space != 0) genlongfree((void *) ModuleArray,space); }
static void ClearBload( void *theEnv) { size_t space; int i; /*=============================================*/ /* Decrement in use counters for atomic values */ /* contained in the construct headers. */ /*=============================================*/ for (i = 0; i < DeftemplateBinaryData(theEnv)->NumberOfDeftemplates; i++) { UnmarkConstructHeader(theEnv,&DeftemplateBinaryData(theEnv)->DeftemplateArray[i].header); } /*=======================================*/ /* Decrement in use counters for symbols */ /* used as slot names. */ /*=======================================*/ for (i = 0; i < DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots; i++) { DecrementSymbolCount(theEnv,DeftemplateBinaryData(theEnv)->SlotArray[i].slotName); } /*======================================================================*/ /* Deallocate the space used for the deftemplateModule data structures. */ /*======================================================================*/ space = DeftemplateBinaryData(theEnv)->NumberOfTemplateModules * sizeof(struct deftemplateModule); if (space != 0) genfree(theEnv,(void *) DeftemplateBinaryData(theEnv)->ModuleArray,space); DeftemplateBinaryData(theEnv)->NumberOfTemplateModules = 0; /*================================================================*/ /* Deallocate the space used for the deftemplate data structures. */ /*================================================================*/ space = DeftemplateBinaryData(theEnv)->NumberOfDeftemplates * sizeof(struct deftemplate); if (space != 0) genfree(theEnv,(void *) DeftemplateBinaryData(theEnv)->DeftemplateArray,space); DeftemplateBinaryData(theEnv)->NumberOfDeftemplates = 0; /*=================================================================*/ /* Deallocate the space used for the templateSlot data structures. */ /*=================================================================*/ space = DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots * sizeof(struct templateSlot); if (space != 0) genfree(theEnv,(void *) DeftemplateBinaryData(theEnv)->SlotArray,space); DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots = 0; /*======================================*/ /* Create the initial-fact deftemplate. */ /*======================================*/ #if (! BLOAD_ONLY) CreateImpliedDeftemplate(theEnv,(SYMBOL_HN *) EnvAddSymbol(theEnv,"initial-fact"),FALSE); #endif }
/*************************************************************** NAME : ClearBloadGenerics DESCRIPTION : Release all binary-loaded generic function structure arrays Resets generic function list to NULL INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : Memory cleared NOTES : Generic function name symbol counts decremented ***************************************************************/ static void ClearBloadGenerics( void *theEnv) { register long i; size_t space; space = (sizeof(DEFGENERIC_MODULE) * DefgenericBinaryData(theEnv)->ModuleCount); if (space == 0L) return; genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->ModuleArray,space); DefgenericBinaryData(theEnv)->ModuleArray = NULL; DefgenericBinaryData(theEnv)->ModuleCount = 0L; for (i = 0 ; i < DefgenericBinaryData(theEnv)->GenericCount ; i++) UnmarkConstructHeader(theEnv,&DefgenericBinaryData(theEnv)->DefgenericArray[i].header); space = (sizeof(DEFGENERIC) * DefgenericBinaryData(theEnv)->GenericCount); if (space == 0L) return; genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->DefgenericArray,space); DefgenericBinaryData(theEnv)->DefgenericArray = NULL; DefgenericBinaryData(theEnv)->GenericCount = 0L; space = (sizeof(DEFMETHOD) * DefgenericBinaryData(theEnv)->MethodCount); if (space == 0L) return; genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->MethodArray,space); DefgenericBinaryData(theEnv)->MethodArray = NULL; DefgenericBinaryData(theEnv)->MethodCount = 0L; space = (sizeof(RESTRICTION) * DefgenericBinaryData(theEnv)->RestrictionCount); if (space == 0L) return; genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->RestrictionArray,space); DefgenericBinaryData(theEnv)->RestrictionArray = NULL; DefgenericBinaryData(theEnv)->RestrictionCount = 0L; #if ! OBJECT_SYSTEM for (i = 0 ; i < DefgenericBinaryData(theEnv)->TypeCount ; i++) DecrementIntegerCount(theEnv,(INTEGER_HN *) DefgenericBinaryData(theEnv)->TypeArray[i]); #endif space = (sizeof(void *) * DefgenericBinaryData(theEnv)->TypeCount); if (space == 0L) return; genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->TypeArray,space); DefgenericBinaryData(theEnv)->TypeArray = NULL; DefgenericBinaryData(theEnv)->TypeCount = 0L; }
/*************************************************************** NAME : ClearBloadGenerics DESCRIPTION : Release all binary-loaded generic function structure arrays Resets generic function list to NULL INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : Memory cleared NOTES : Generic function name symbol counts decremented ***************************************************************/ static void ClearBloadGenerics() { register long i; unsigned long space; space = (unsigned long) (sizeof(DEFGENERIC_MODULE) * ModuleCount); if (space == 0L) return; genlongfree((void *) ModuleArray,space); ModuleArray = NULL; ModuleCount = 0L; for (i = 0 ; i < GenericCount ; i++) UnmarkConstructHeader(&defgenericArray[i].header); space = (unsigned long) (sizeof(DEFGENERIC) * GenericCount); if (space == 0L) return; genlongfree((void *) defgenericArray,space); defgenericArray = NULL; GenericCount = 0L; space = (unsigned long) (sizeof(DEFMETHOD) * MethodCount); if (space == 0L) return; genlongfree((void *) methodArray,space); methodArray = NULL; MethodCount = 0L; space = (unsigned long) (sizeof(RESTRICTION) * RestrictionCount); if (space == 0L) return; genlongfree((void *) restrictionArray,space); restrictionArray = NULL; RestrictionCount = 0L; #if ! OBJECT_SYSTEM for (i = 0 ; i < TypeCount ; i++) DecrementIntegerCount((INTEGER_HN *) typeArray[i]); #endif space = (unsigned long) (sizeof(void *) * TypeCount); if (space == 0L) return; genlongfree((void *) typeArray,space); typeArray = NULL; TypeCount = 0L; }
static void ClearBload( Environment *theEnv) { size_t space; unsigned long i; /*=============================================*/ /* Decrement in use counters for atomic values */ /* contained in the construct headers. */ /*=============================================*/ for (i = 0; i < DeftemplateBinaryData(theEnv)->NumberOfDeftemplates; i++) { UnmarkConstructHeader(theEnv,&DeftemplateBinaryData(theEnv)->DeftemplateArray[i].header); } /*=======================================*/ /* Decrement in use counters for symbols */ /* used as slot names. */ /*=======================================*/ for (i = 0; i < DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots; i++) { ReleaseLexeme(theEnv,DeftemplateBinaryData(theEnv)->SlotArray[i].slotName); } /*======================================================================*/ /* Deallocate the space used for the deftemplateModule data structures. */ /*======================================================================*/ space = DeftemplateBinaryData(theEnv)->NumberOfTemplateModules * sizeof(struct deftemplateModule); if (space != 0) genfree(theEnv,DeftemplateBinaryData(theEnv)->ModuleArray,space); DeftemplateBinaryData(theEnv)->NumberOfTemplateModules = 0; /*================================================================*/ /* Deallocate the space used for the deftemplate data structures. */ /*================================================================*/ space = DeftemplateBinaryData(theEnv)->NumberOfDeftemplates * sizeof(Deftemplate); if (space != 0) genfree(theEnv,DeftemplateBinaryData(theEnv)->DeftemplateArray,space); DeftemplateBinaryData(theEnv)->NumberOfDeftemplates = 0; /*=================================================================*/ /* Deallocate the space used for the templateSlot data structures. */ /*=================================================================*/ space = DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots * sizeof(struct templateSlot); if (space != 0) genfree(theEnv,DeftemplateBinaryData(theEnv)->SlotArray,space); DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots = 0; }
/*************************************************************** NAME : ClearDeffunctionBload DESCRIPTION : Release all binary-loaded deffunction structure arrays Resets deffunction list to NULL INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : Memory cleared NOTES : Deffunction name symbol counts decremented ***************************************************************/ static void ClearDeffunctionBload() { register long i; unsigned long space; space = (unsigned long) (sizeof(DEFFUNCTION_MODULE) * ModuleCount); if (space == 0L) return; genlongfree((void *) ModuleArray,space); ModuleArray = NULL; ModuleCount = 0L; for (i = 0L ; i < DeffunctionCount ; i++) UnmarkConstructHeader(&deffunctionArray[i].header); space = (unsigned long) (sizeof(DEFFUNCTION) * DeffunctionCount); if (space == 0L) return; genlongfree((void *) deffunctionArray,space); deffunctionArray = NULL; DeffunctionCount = 0L; }
/*************************************************************** NAME : ClearDeffunctionBload DESCRIPTION : Release all binary-loaded deffunction structure arrays Resets deffunction list to NULL INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : Memory cleared NOTES : Deffunction name symbol counts decremented ***************************************************************/ static void ClearDeffunctionBload( void *theEnv) { register long i; size_t space; space = (sizeof(DEFFUNCTION_MODULE) * DeffunctionBinaryData(theEnv)->ModuleCount); if (space == 0L) return; genfree(theEnv,(void *) DeffunctionBinaryData(theEnv)->ModuleArray,space); DeffunctionBinaryData(theEnv)->ModuleArray = NULL; DeffunctionBinaryData(theEnv)->ModuleCount = 0L; for (i = 0L ; i < DeffunctionBinaryData(theEnv)->DeffunctionCount ; i++) UnmarkConstructHeader(theEnv,&DeffunctionBinaryData(theEnv)->DeffunctionArray[i].header); space = (sizeof(DEFFUNCTION) * DeffunctionBinaryData(theEnv)->DeffunctionCount); if (space == 0L) return; genfree(theEnv,(void *) DeffunctionBinaryData(theEnv)->DeffunctionArray,space); DeffunctionBinaryData(theEnv)->DeffunctionArray = NULL; DeffunctionBinaryData(theEnv)->DeffunctionCount = 0L; }
/*************************************************************** NAME : ClearDefinstancesBload DESCRIPTION : Release all binary-loaded definstances structure arrays Resets definstances list to NULL INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : Memory cleared NOTES : Definstances name symbol counts decremented ***************************************************************/ static void ClearDefinstancesBload( void *theEnv) { register long i; unsigned long space; space = (unsigned long) (sizeof(DEFINSTANCES_MODULE) * DefinstancesBinaryData(theEnv)->ModuleCount); if (space == 0L) return; genlongfree(theEnv,(void *) DefinstancesBinaryData(theEnv)->ModuleArray,space); DefinstancesBinaryData(theEnv)->ModuleArray = NULL; DefinstancesBinaryData(theEnv)->ModuleCount = 0L; for (i = 0L ; i < DefinstancesBinaryData(theEnv)->DefinstancesCount ; i++) UnmarkConstructHeader(theEnv,&DefinstancesBinaryData(theEnv)->DefinstancesArray[i].header); space = (unsigned long) (sizeof(DEFINSTANCES) * DefinstancesBinaryData(theEnv)->DefinstancesCount); if (space == 0L) return; genlongfree(theEnv,(void *) DefinstancesBinaryData(theEnv)->DefinstancesArray,space); DefinstancesBinaryData(theEnv)->DefinstancesArray = NULL; DefinstancesBinaryData(theEnv)->DefinstancesCount = 0L; }
static void ClearBload( void *theEnv, EXEC_STATUS) { long i; size_t space; /*=======================================================*/ /* Decrement in use counters for atomic values contained */ /* in the construct headers. Also decrement data */ /* structures used to store the defglobal's value. */ /*=======================================================*/ for (i = 0; i < DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals; i++) { UnmarkConstructHeader(theEnv,execStatus,&DefglobalBinaryData(theEnv,execStatus)->DefglobalArray[i].header); ValueDeinstall(theEnv,execStatus,&(DefglobalBinaryData(theEnv,execStatus)->DefglobalArray[i].current)); if (DefglobalBinaryData(theEnv,execStatus)->DefglobalArray[i].current.type == MULTIFIELD) { ReturnMultifield(theEnv,execStatus,(struct multifield *) DefglobalBinaryData(theEnv,execStatus)->DefglobalArray[i].current.value); } } /*==============================================================*/ /* Deallocate the space used for the defglobal data structures. */ /*==============================================================*/ space = DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals * sizeof(struct defglobal); if (space != 0) genfree(theEnv,execStatus,(void *) DefglobalBinaryData(theEnv,execStatus)->DefglobalArray,space); DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals = 0; /*=====================================================================*/ /* Deallocate the space used for the defglobal module data structures. */ /*=====================================================================*/ space = DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobalModules * sizeof(struct defglobalModule); if (space != 0) genfree(theEnv,execStatus,(void *) DefglobalBinaryData(theEnv,execStatus)->ModuleArray,space); DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobalModules = 0; }
static void ClearBload() { unsigned long int space; long i; struct patternParser *theParser = NULL; struct patternEntity *theEntity = NULL; void *theModule; /*===========================================*/ /* Delete all known entities before removing */ /* the defrule data structures. */ /*===========================================*/ GetNextPatternEntity(&theParser,&theEntity); while (theEntity != NULL) { (*theEntity->theInfo->base.deleteFunction)(theEntity); theEntity = NULL; GetNextPatternEntity(&theParser,&theEntity); } /*=========================================*/ /* Remove all activations from the agenda. */ /*=========================================*/ SaveCurrentModule(); for (theModule = GetNextDefmodule(NULL); theModule != NULL; theModule = GetNextDefmodule(theModule)) { SetCurrentModule(theModule); RemoveAllActivations(); } RestoreCurrentModule(); ClearFocusStack(); /*==========================================================*/ /* Remove all partial matches from the beta memories in the */ /* join network. Alpha memories do not need to be examined */ /* since all pattern entities have been deleted by now. */ /*==========================================================*/ for (i = 0; i < NumberOfJoins; i++) { FlushAlphaBetaMemory(JoinArray[i].beta); } /*================================================*/ /* Decrement the symbol count for each rule name. */ /*================================================*/ for (i = 0; i < NumberOfDefrules; i++) { UnmarkConstructHeader(&DefruleArray[i].header); } /*==================================================*/ /* Return the space allocated for the bload arrays. */ /*==================================================*/ space = NumberOfDefruleModules * sizeof(struct defruleModule); if (space != 0) genlongfree((void *) ModuleArray,space); space = NumberOfDefrules * sizeof(struct defrule); if (space != 0) genlongfree((void *) DefruleArray,space); #if FUZZY_DEFTEMPLATES space = NumberOfPatternFuzzyValues * sizeof(struct fzSlotLocator); if (space != 0) genlongfree((void *) PatternFuzzyValueArray,space); #endif space = NumberOfJoins * sizeof(struct joinNode); if (space != 0) genlongfree((void *) JoinArray,space); }
static void ClearBload( void *theEnv) { unsigned long int space; long i; struct patternParser *theParser = NULL; struct patternEntity *theEntity = NULL; void *theModule; /*===========================================*/ /* Delete all known entities before removing */ /* the defrule data structures. */ /*===========================================*/ GetNextPatternEntity(theEnv,&theParser,&theEntity); while (theEntity != NULL) { (*theEntity->theInfo->base.deleteFunction)(theEnv,theEntity); theEntity = NULL; GetNextPatternEntity(theEnv,&theParser,&theEntity); } /*=========================================*/ /* Remove all activations from the agenda. */ /*=========================================*/ SaveCurrentModule(theEnv); for (theModule = EnvGetNextDefmodule(theEnv,NULL); theModule != NULL; theModule = EnvGetNextDefmodule(theEnv,theModule)) { EnvSetCurrentModule(theEnv,theModule); RemoveAllActivations(theEnv); } RestoreCurrentModule(theEnv); EnvClearFocusStack(theEnv); /*==========================================================*/ /* Remove all partial matches from the beta memories in the */ /* join network. Alpha memories do not need to be examined */ /* since all pattern entities have been deleted by now. */ /*==========================================================*/ for (i = 0; i < DefruleBinaryData(theEnv)->NumberOfJoins; i++) { FlushAlphaBetaMemory(theEnv,DefruleBinaryData(theEnv)->JoinArray[i].beta); } /*================================================*/ /* Decrement the symbol count for each rule name. */ /*================================================*/ for (i = 0; i < DefruleBinaryData(theEnv)->NumberOfDefrules; i++) { UnmarkConstructHeader(theEnv,&DefruleBinaryData(theEnv)->DefruleArray[i].header); } /*==================================================*/ /* Return the space allocated for the bload arrays. */ /*==================================================*/ space = DefruleBinaryData(theEnv)->NumberOfDefruleModules * sizeof(struct defruleModule); if (space != 0) genlongfree(theEnv,(void *) DefruleBinaryData(theEnv)->ModuleArray,space); DefruleBinaryData(theEnv)->NumberOfDefruleModules = 0; space = DefruleBinaryData(theEnv)->NumberOfDefrules * sizeof(struct defrule); if (space != 0) genlongfree(theEnv,(void *) DefruleBinaryData(theEnv)->DefruleArray,space); DefruleBinaryData(theEnv)->NumberOfDefrules = 0; space = DefruleBinaryData(theEnv)->NumberOfJoins * sizeof(struct joinNode); if (space != 0) genlongfree(theEnv,(void *) DefruleBinaryData(theEnv)->JoinArray,space); DefruleBinaryData(theEnv)->NumberOfJoins = 0; }
/*************************************************************** NAME : ClearBloadObjects DESCRIPTION : Release all binary-loaded class and handler structure arrays (and others) INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : Memory cleared NOTES : None ***************************************************************/ static void ClearBloadObjects() { register long i; UNLN space; space = (unsigned long) (sizeof(DEFCLASS_MODULE) * ModuleCount); if (space == 0L) return; genlongfree((void *) ModuleArray,space); ModuleArray = NULL; ModuleCount = 0L; if (ClassCount != 0L) { rm((void *) ClassIDMap,(int) (sizeof(DEFCLASS *) * MaxClassID)); ClassIDMap = NULL; MaxClassID = 0; for (i = 0L ; i < ClassCount ; i++) { UnmarkConstructHeader(&defclassArray[i].header); #if DEFMODULE_CONSTRUCT DecrementBitMapCount(defclassArray[i].scopeMap); #endif RemoveClassFromTable((DEFCLASS *) &defclassArray[i]); } for (i = 0L ; i < SlotCount ; i++) { DecrementSymbolCount(slotArray[i].overrideMessage); if ((slotArray[i].defaultValue != NULL) && (slotArray[i].dynamicDefault == 0)) { ValueDeinstall((DATA_OBJECT *) slotArray[i].defaultValue); rtn_struct(dataObject,slotArray[i].defaultValue); } } for (i = 0L ; i < SlotNameCount ; i++) { SlotNameTable[slotNameArray[i].hashTableIndex] = NULL; DecrementSymbolCount(slotNameArray[i].name); DecrementSymbolCount(slotNameArray[i].putHandlerName); } space = (UNLN) (sizeof(DEFCLASS) * ClassCount); if (space != 0L) { genlongfree((void *) defclassArray,space); defclassArray = NULL; ClassCount = 0L; } space = (UNLN) (sizeof(DEFCLASS *) * LinkCount); if (space != 0L) { genlongfree((void *) linkArray,space); linkArray = NULL; LinkCount = 0L; } space = (UNLN) (sizeof(SLOT_DESC) * SlotCount); if (space != 0L) { genlongfree((void *) slotArray,space); slotArray = NULL; SlotCount = 0L; } space = (UNLN) (sizeof(SLOT_NAME) * SlotNameCount); if (space != 0L) { genlongfree((void *) slotNameArray,space); slotNameArray = NULL; SlotNameCount = 0L; } space = (UNLN) (sizeof(SLOT_DESC *) * TemplateSlotCount); if (space != 0L) { genlongfree((void *) tmpslotArray,space); tmpslotArray = NULL; TemplateSlotCount = 0L; } space = (UNLN) (sizeof(unsigned) * SlotNameMapCount); if (space != 0L) { genlongfree((void *) mapslotArray,space); mapslotArray = NULL; SlotNameMapCount = 0L; } } if (HandlerCount != 0L) { for (i = 0L ; i < HandlerCount ; i++) DecrementSymbolCount(handlerArray[i].name); space = (UNLN) (sizeof(HANDLER) * HandlerCount); if (space != 0L) { genlongfree((void *) handlerArray,space); handlerArray = NULL; space = (UNLN) (sizeof(unsigned) * HandlerCount); genlongfree((void *) maphandlerArray,space); maphandlerArray = NULL; HandlerCount = 0L; } } }