/*************************************************** NAME : ClearBloadObjectPatterns DESCRIPTION : Releases all emmory associated with binary image object patterns INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : Memory released and global network pointers set to NULL NOTES : None ***************************************************/ static void ClearBloadObjectPatterns() { UNLN space; register long i; /* ================================================ All instances have been deleted by this point so we don't need to worry about clearing partial matches ================================================ */ for (i = 0L ; i < AlphaNodeCount ; i++) { DecrementBitMapCount(AlphaArray[i].classbmp); if (AlphaArray[i].slotbmp != NULL) DecrementBitMapCount(AlphaArray[i].slotbmp); } if (AlphaNodeCount != 0L) { space = (UNLN) (AlphaNodeCount * sizeof(OBJECT_ALPHA_NODE)); genlongfree((void *) AlphaArray,space); AlphaArray = NULL; space = (UNLN) (PatternNodeCount * sizeof(OBJECT_PATTERN_NODE)); genlongfree((void *) PatternArray,space); PatternArray = NULL; } SetObjectNetworkTerminalPointer(NULL); SetObjectNetworkPointer(NULL); #if BLOAD_ONLY ResetObjectMatchTimeTags(); #endif }
/*************************************************** NAME : ClearBloadObjectPatterns DESCRIPTION : Releases all emmory associated with binary image object patterns INPUTS : None RETURNS : Nothing useful SIDE EFFECTS : Memory released and global network pointers set to NULL NOTES : None ***************************************************/ static void ClearBloadObjectPatterns( void *theEnv, EXEC_STATUS) { size_t space; register long i; for (i = 0; i < ObjectReteBinaryData(theEnv,execStatus)->PatternNodeCount; i++) { if ((ObjectReteBinaryData(theEnv,execStatus)->PatternArray[i].lastLevel != NULL) && (ObjectReteBinaryData(theEnv,execStatus)->PatternArray[i].lastLevel->selector)) { RemoveHashedPatternNode(theEnv,execStatus,ObjectReteBinaryData(theEnv,execStatus)->PatternArray[i].lastLevel, &ObjectReteBinaryData(theEnv,execStatus)->PatternArray[i], ObjectReteBinaryData(theEnv,execStatus)->PatternArray[i].networkTest->type, ObjectReteBinaryData(theEnv,execStatus)->PatternArray[i].networkTest->value); } } /* ================================================ All instances have been deleted by this point so we don't need to worry about clearing partial matches ================================================ */ for (i = 0L ; i < ObjectReteBinaryData(theEnv,execStatus)->AlphaNodeCount ; i++) { DecrementBitMapCount(theEnv,execStatus,ObjectReteBinaryData(theEnv,execStatus)->AlphaArray[i].classbmp); if (ObjectReteBinaryData(theEnv,execStatus)->AlphaArray[i].slotbmp != NULL) DecrementBitMapCount(theEnv,execStatus,ObjectReteBinaryData(theEnv,execStatus)->AlphaArray[i].slotbmp); } if (ObjectReteBinaryData(theEnv,execStatus)->AlphaNodeCount != 0L) { space = (ObjectReteBinaryData(theEnv,execStatus)->AlphaNodeCount * sizeof(OBJECT_ALPHA_NODE)); genfree(theEnv,execStatus,(void *) ObjectReteBinaryData(theEnv,execStatus)->AlphaArray,space); ObjectReteBinaryData(theEnv,execStatus)->AlphaArray = NULL; ObjectReteBinaryData(theEnv,execStatus)->AlphaNodeCount = 0; space = (ObjectReteBinaryData(theEnv,execStatus)->PatternNodeCount * sizeof(OBJECT_PATTERN_NODE)); genfree(theEnv,execStatus,(void *) ObjectReteBinaryData(theEnv,execStatus)->PatternArray,space); ObjectReteBinaryData(theEnv,execStatus)->PatternArray = NULL; ObjectReteBinaryData(theEnv,execStatus)->PatternNodeCount = 0; } SetObjectNetworkTerminalPointer(theEnv,execStatus,NULL); SetObjectNetworkPointer(theEnv,execStatus,NULL); #if BLOAD_ONLY ResetObjectMatchTimeTags(theEnv,execStatus); #endif }
/*************************************************** NAME : UpdateDefclassesScope DESCRIPTION : This function updates the scope bitmaps for existing classes when a new module is defined INPUTS : None RETURNS : Nothing SIDE EFFECTS : Class scope bitmaps are updated NOTES : None ***************************************************/ static void UpdateDefclassesScope( void *theEnv) { register unsigned i; DEFCLASS *theDefclass; int newModuleID,count; char *newScopeMap; unsigned newScopeMapSize; char *className; struct defmodule *matchModule; newModuleID = (int) ((struct defmodule *) EnvGetCurrentModule(theEnv))->bsaveID; newScopeMapSize = (sizeof(char) * ((GetNumberOfDefmodules(theEnv) / BITS_PER_BYTE) + 1)); newScopeMap = (char *) gm2(theEnv,newScopeMapSize); for (i = 0 ; i < CLASS_TABLE_HASH_SIZE ; i++) for (theDefclass = DefclassData(theEnv)->ClassTable[i] ; theDefclass != NULL ; theDefclass = theDefclass->nxtHash) { matchModule = theDefclass->header.whichModule->theModule; className = ValueToString(theDefclass->header.name); ClearBitString((void *) newScopeMap,newScopeMapSize); GenCopyMemory(char,theDefclass->scopeMap->size, newScopeMap,ValueToBitMap(theDefclass->scopeMap)); DecrementBitMapCount(theEnv,theDefclass->scopeMap); if (theDefclass->system) SetBitMap(newScopeMap,newModuleID); else if (FindImportedConstruct(theEnv,(char*)"defclass",matchModule, className,&count,TRUE,NULL) != NULL) SetBitMap(newScopeMap,newModuleID); theDefclass->scopeMap = (BITMAP_HN *) EnvAddBitMap(theEnv,(void *) newScopeMap,newScopeMapSize); IncrementBitMapCount(theDefclass->scopeMap); } rm(theEnv,(void *) newScopeMap,newScopeMapSize); }
globle void AtomDeinstall( int type, void *vPtr) { switch (type) { case SYMBOL: case STRING: #if DEFGLOBAL_CONSTRUCT case GBL_VARIABLE: #endif #if OBJECT_SYSTEM case INSTANCE_NAME: #endif DecrementSymbolCount((SYMBOL_HN *) vPtr); break; case FLOAT: DecrementFloatCount((FLOAT_HN *) vPtr); break; case INTEGER: DecrementIntegerCount((INTEGER_HN *) vPtr); break; #if FUZZY_DEFTEMPLATES case FUZZY_VALUE: DeinstallFuzzyValue(vPtr); break; #endif case MULTIFIELD: MultifieldDeinstall((struct multifield *) vPtr); break; case RVOID: break; default: if (PrimitivesArray[type] == NULL) break; if (PrimitivesArray[type]->bitMap) DecrementBitMapCount((BITMAP_HN *) vPtr); else if (PrimitivesArray[type]->decrementBusyCount) { (*PrimitivesArray[type]->decrementBusyCount)(vPtr); } } }
globle void AtomDeinstall( void *theEnv, int type, void *vPtr) { switch (type) { case SYMBOL: case STRING: #if DEFGLOBAL_CONSTRUCT case GBL_VARIABLE: #endif #if OBJECT_SYSTEM case INSTANCE_NAME: #endif DecrementSymbolCount(theEnv,(SYMBOL_HN *) vPtr); break; case FLOAT: DecrementFloatCount(theEnv,(FLOAT_HN *) vPtr); break; case INTEGER: DecrementIntegerCount(theEnv,(INTEGER_HN *) vPtr); break; case EXTERNAL_ADDRESS: DecrementExternalAddressCount(theEnv,(EXTERNAL_ADDRESS_HN *) vPtr); break; case MULTIFIELD: MultifieldDeinstall(theEnv,(struct multifield *) vPtr); break; case RVOID: break; default: if (EvaluationData(theEnv)->PrimitivesArray[type] == NULL) break; if (EvaluationData(theEnv)->PrimitivesArray[type]->bitMap) DecrementBitMapCount(theEnv,(BITMAP_HN *) vPtr); else if (EvaluationData(theEnv)->PrimitivesArray[type]->decrementBusyCount) { (*EvaluationData(theEnv)->PrimitivesArray[type]->decrementBusyCount)(theEnv,vPtr); } } }
/*************************************************************** 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; } } }