static void DeallocateConstructData( void *theEnv) { struct construct *tmpPtr, *nextPtr; #if (! RUN_TIME) && (! BLOAD_ONLY) DeallocateCallList(theEnv,ConstructData(theEnv)->ListOfSaveFunctions); #endif DeallocateCallList(theEnv,ConstructData(theEnv)->ListOfResetFunctions); DeallocateCallList(theEnv,ConstructData(theEnv)->ListOfClearFunctions); DeallocateCallList(theEnv,ConstructData(theEnv)->ListOfClearReadyFunctions); #if (! RUN_TIME) && (! BLOAD_ONLY) if (ConstructData(theEnv)->ErrorString != NULL) { genfree(theEnv,ConstructData(theEnv)->ErrorString,sizeof(ConstructData(theEnv)->ErrorString) + 1); } if (ConstructData(theEnv)->WarningString != NULL) { genfree(theEnv,ConstructData(theEnv)->WarningString,sizeof(ConstructData(theEnv)->WarningString) + 1); } ConstructData(theEnv)->ErrorString = NULL; ConstructData(theEnv)->WarningString = NULL; EnvSetParsingFileName(theEnv,NULL); EnvSetWarningFileName(theEnv,NULL); EnvSetErrorFileName(theEnv,NULL); #endif tmpPtr = ConstructData(theEnv)->ListOfConstructs; while (tmpPtr != NULL) { nextPtr = tmpPtr->next; rtn_struct(theEnv,construct,tmpPtr); tmpPtr = nextPtr; } }
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; }
globle int genlongfree( void *theEnv, void *ptr, unsigned long size) { #if (! MAC) && (! IBM_TBC) && (! IBM_MSC) && (! IBM_ICB) && (! IBM_ZTC) && (! IBM_SC) && (! IBM_MCW) unsigned int test; #endif #if BLOCK_MEMORY struct longMemoryPtr *theLongMemory; #endif if (sizeof(unsigned int) == sizeof(unsigned long)) { return(genfree(theEnv,(void *) ptr,(unsigned) size)); } #if (! MAC) && (! IBM_TBC) && (! IBM_MSC) && (! IBM_ICB) && (! IBM_ZTC) && (! IBM_SC) && (! IBM_MCW) test = (unsigned int) size; if (test != size) return(-1); return(genfree(theEnv,(void *) ptr,(unsigned) test)); #endif #if BLOCK_MEMORY size += sizeof(struct longMemoryPtr); theLongMemory = ((struct longMemoryPtr *) ptr) - 1; if (theLongMemory->prev == NULL) { MemoryData(theEnv)->TopLongMemoryPtr = MemoryData(theEnv)->TopLongMemoryPtr->next; MemoryData(theEnv)->TopLongMemoryPtr->prev = NULL; } else { theLongMemory->prev->next = theLongMemory->next; if (theLongMemory->next != NULL) { theLongMemory->next->prev = theLongMemory->next; } } #endif #if MAC || IBM_ICB || IBM_MCW MemoryData(theEnv)->MemoryAmount -= (long) size; MemoryData(theEnv)->MemoryCalls--; SpecialFree(ptr); return(0); #endif #if IBM_TBC || IBM_ZTC || IBM_SC MemoryData(theEnv)->MemoryAmount -= size; MemoryData(theEnv)->MemoryCalls--; SpecialFree(ptr); return(0); #endif #if IBM_MSC MemoryData(theEnv)->MemoryAmount -= size; MemoryData(theEnv)->MemoryCalls--; SpecialFree(ptr); return(0); #endif }
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 }
static void DeallocateDeffactsBloadData( void *theEnv) { size_t space; space = DeffactsBinaryData(theEnv)->NumberOfDeffacts * sizeof(struct deffacts); if (space != 0) genfree(theEnv,(void *) DeffactsBinaryData(theEnv)->DeffactsArray,space); space = DeffactsBinaryData(theEnv)->NumberOfDeffactsModules * sizeof(struct deffactsModule); if (space != 0) genfree(theEnv,(void *) DeffactsBinaryData(theEnv)->ModuleArray,space); }
static void DeallocateDeffunctionBloadData( void *theEnv) { size_t space; #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) space = DeffunctionBinaryData(theEnv)->DeffunctionCount * sizeof(struct deffunctionStruct); if (space != 0) genfree(theEnv,(void *) DeffunctionBinaryData(theEnv)->DeffunctionArray,space); space = DeffunctionBinaryData(theEnv)->ModuleCount * sizeof(struct deffunctionModule); if (space != 0) genfree(theEnv,(void *) DeffunctionBinaryData(theEnv)->ModuleArray,space); #endif }
static void DeallocateDefinstancesBinaryData( void *theEnv) { size_t space; #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) space = DefinstancesBinaryData(theEnv)->DefinstancesCount * sizeof(struct definstances); if (space != 0) genfree(theEnv,(void *) DefinstancesBinaryData(theEnv)->DefinstancesArray,space); space = DefinstancesBinaryData(theEnv)->ModuleCount * sizeof(struct definstancesModule); if (space != 0) genfree(theEnv,(void *) DefinstancesBinaryData(theEnv)->ModuleArray,space); #endif }
static void DeallocateDeftemplateBloadData( Environment *theEnv) { size_t space; space = DeftemplateBinaryData(theEnv)->NumberOfTemplateModules * sizeof(struct deftemplateModule); if (space != 0) genfree(theEnv,DeftemplateBinaryData(theEnv)->ModuleArray,space); space = DeftemplateBinaryData(theEnv)->NumberOfDeftemplates * sizeof(Deftemplate); if (space != 0) genfree(theEnv,DeftemplateBinaryData(theEnv)->DeftemplateArray,space); space = DeftemplateBinaryData(theEnv)->NumberOfTemplateSlots * sizeof(struct templateSlot); if (space != 0) genfree(theEnv,DeftemplateBinaryData(theEnv)->SlotArray,space); }
/*************************************************** 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 : 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; }
globle int EnvDeleteRouter( void *theEnv, char *routerName) { struct router *currentPtr, *lastPtr; currentPtr = RouterData(theEnv)->ListOfRouters; lastPtr = NULL; while (currentPtr != NULL) { if (strcmp(currentPtr->name,routerName) == 0) { genfree(theEnv,currentPtr->name,strlen(currentPtr->name) + 1); if (lastPtr == NULL) { RouterData(theEnv)->ListOfRouters = currentPtr->next; rm(theEnv,currentPtr,(int) sizeof(struct router)); return(1); } lastPtr->next = currentPtr->next; rm(theEnv,currentPtr,(int) sizeof(struct router)); return(1); } lastPtr = currentPtr; currentPtr = currentPtr->next; } return(0); }
static void DeallocateScannerData( void *theEnv, EXEC_STATUS) { if (ScannerData(theEnv,execStatus)->GlobalMax != 0) { genfree(theEnv,execStatus,ScannerData(theEnv,execStatus)->GlobalString,ScannerData(theEnv,execStatus)->GlobalMax); } }
static void DeallocateExternalFunctionData( void *theEnv) { struct FunctionHash *fhPtr, *nextFHPtr; int i; #if ! RUN_TIME struct FunctionDefinition *tmpPtr, *nextPtr; tmpPtr = ExternalFunctionData(theEnv)->ListOfFunctions; while (tmpPtr != NULL) { nextPtr = tmpPtr->next; rtn_struct(theEnv,FunctionDefinition,tmpPtr); tmpPtr = nextPtr; } #endif if (ExternalFunctionData(theEnv)->FunctionHashtable == NULL) { return; } for (i = 0; i < SIZE_FUNCTION_HASH; i++) { fhPtr = ExternalFunctionData(theEnv)->FunctionHashtable[i]; while (fhPtr != NULL) { nextFHPtr = fhPtr->next; rtn_struct(theEnv,FunctionHash,fhPtr); fhPtr = nextFHPtr; } } genfree(theEnv,ExternalFunctionData(theEnv)->FunctionHashtable, (int) sizeof (struct FunctionHash *) * SIZE_FUNCTION_HASH); }
globle long int EnvReleaseMem( void *theEnv, long int maximum) { struct memoryPtr *tmpPtr, *memPtr; int i; long int returns = 0; long int amount = 0; for (i = (MEM_TABLE_SIZE - 1) ; i >= (int) sizeof(char *) ; i--) { YieldTime(theEnv); memPtr = MemoryData(theEnv)->MemoryTable[i]; while (memPtr != NULL) { tmpPtr = memPtr->next; genfree(theEnv,(void *) memPtr,(unsigned) i); memPtr = tmpPtr; amount += i; returns++; if ((returns % 100) == 0) { YieldTime(theEnv); } } MemoryData(theEnv)->MemoryTable[i] = NULL; if ((amount > maximum) && (maximum > 0)) { return(amount); } } return(amount); }
void MergeSort( void *theEnv, unsigned long listSize, DATA_OBJECT *theList, int (*swapFunction)(void *,DATA_OBJECT *,DATA_OBJECT *)) { DATA_OBJECT *tempList; unsigned long middle; if (listSize <= 1) return; /*==============================*/ /* Create the temporary storage */ /* needed for the merge sort. */ /*==============================*/ tempList = (DATA_OBJECT *) genalloc(theEnv,listSize * sizeof(DATA_OBJECT)); /*=====================================*/ /* Call the merge sort driver routine. */ /*=====================================*/ middle = (listSize + 1) / 2; DoMergeSort(theEnv,theList,tempList,0,middle-1,middle,listSize - 1,swapFunction); /*==================================*/ /* Deallocate the temporary storage */ /* needed by the merge sort. */ /*==================================*/ genfree(theEnv,tempList,listSize * sizeof(DATA_OBJECT)); }
static void DeallocateConstraintData( Environment *theEnv) { #if ! RUN_TIME struct constraintRecord *tmpPtr, *nextPtr; int i; for (i = 0; i < SIZE_CONSTRAINT_HASH; i++) { tmpPtr = ConstraintData(theEnv)->ConstraintHashtable[i]; while (tmpPtr != NULL) { nextPtr = tmpPtr->next; ReturnConstraintRecord(theEnv,tmpPtr); tmpPtr = nextPtr; } } rm(theEnv,ConstraintData(theEnv)->ConstraintHashtable, sizeof(struct constraintRecord *) * SIZE_CONSTRAINT_HASH); #else #if MAC_XCD #pragma unused(theEnv) #endif #endif #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) if (ConstraintData(theEnv)->NumberOfConstraints != 0) { genfree(theEnv,ConstraintData(theEnv)->ConstraintArray, (sizeof(CONSTRAINT_RECORD) * ConstraintData(theEnv)->NumberOfConstraints)); } #endif }
struct saveCallFunctionItem *RemoveSaveFunctionFromCallList( Environment *theEnv, const char *name, struct saveCallFunctionItem *head, bool *found) { struct saveCallFunctionItem *currentPtr, *lastPtr; *found = false; lastPtr = NULL; currentPtr = head; while (currentPtr != NULL) { if (strcmp(name,currentPtr->name) == 0) { *found = true; if (lastPtr == NULL) { head = currentPtr->next; } else { lastPtr->next = currentPtr->next; } genfree(theEnv,(void *) currentPtr->name,strlen(currentPtr->name) + 1); rtn_struct(theEnv,saveCallFunctionItem,currentPtr); return head; } lastPtr = currentPtr; currentPtr = currentPtr->next; } return head; }
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; }
void ClearBloadedExpressions( Environment *theEnv) { unsigned long i; size_t space; /*===============================================*/ /* Update the busy counts of atomic data values. */ /*===============================================*/ for (i = 0; i < ExpressionData(theEnv)->NumberOfExpressions; i++) { switch (ExpressionData(theEnv)->ExpressionArray[i].type) { case SYMBOL_TYPE : case STRING_TYPE : case INSTANCE_NAME_TYPE : case GBL_VARIABLE : ReleaseLexeme(theEnv,ExpressionData(theEnv)->ExpressionArray[i].lexemeValue); break; case FLOAT_TYPE : ReleaseFloat(theEnv,ExpressionData(theEnv)->ExpressionArray[i].floatValue); break; case INTEGER_TYPE : ReleaseInteger(theEnv,ExpressionData(theEnv)->ExpressionArray[i].integerValue); break; #if DEFTEMPLATE_CONSTRUCT case FACT_ADDRESS_TYPE : ReleaseFact((Fact *) ExpressionData(theEnv)->ExpressionArray[i].value); break; #endif #if OBJECT_SYSTEM case INSTANCE_ADDRESS_TYPE : ReleaseInstance((Instance *) ExpressionData(theEnv)->ExpressionArray[i].value); break; #endif case VOID_TYPE: break; default: if (EvaluationData(theEnv)->PrimitivesArray[ExpressionData(theEnv)->ExpressionArray[i].type] == NULL) break; if (EvaluationData(theEnv)->PrimitivesArray[ExpressionData(theEnv)->ExpressionArray[i].type]->bitMap) { DecrementBitMapReferenceCount(theEnv,(CLIPSBitMap *) ExpressionData(theEnv)->ExpressionArray[i].value); } break; } } /*===================================*/ /* Free the binary expression array. */ /*===================================*/ space = ExpressionData(theEnv)->NumberOfExpressions * sizeof(struct expr); if (space != 0) genfree(theEnv,ExpressionData(theEnv)->ExpressionArray,space); ExpressionData(theEnv)->ExpressionArray = 0; }
static void DeallocateObjectReteBinaryData( void *theEnv) { #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) size_t space; long i; for (i = 0; i < ObjectReteBinaryData(theEnv)->AlphaNodeCount; i++) { DestroyAlphaMemory(theEnv,&ObjectReteBinaryData(theEnv)->AlphaArray[i].header,false); } space = ObjectReteBinaryData(theEnv)->AlphaNodeCount * sizeof(struct objectAlphaNode); if (space != 0) genfree(theEnv,(void *) ObjectReteBinaryData(theEnv)->AlphaArray,space); space = ObjectReteBinaryData(theEnv)->PatternNodeCount * sizeof(struct objectPatternNode); if (space != 0) genfree(theEnv,(void *) ObjectReteBinaryData(theEnv)->PatternArray,space); #endif }
globle void ClearBloadedConstraints( void *theEnv) { if (ConstraintData(theEnv)->NumberOfConstraints != 0) { genfree(theEnv,(void *) ConstraintData(theEnv)->ConstraintArray, (sizeof(CONSTRAINT_RECORD) * ConstraintData(theEnv)->NumberOfConstraints)); ConstraintData(theEnv)->NumberOfConstraints = 0; } }
globle int kill_all_buffers( void *theEnv, BUFFER **top_buf) { register BUFFER *bp; bp = *top_buf; while(bp != NULL) { spec_clear(theEnv,bp); /* Blow text away. */ genfree(theEnv,(void *) bp->b_linep, /* And free pointer */ (unsigned) sizeof(LINE)+ bp->b_linep->l_size); *top_buf = bp->b_bufp; /* Find next buffer */ genfree(theEnv,(void *) bp, (unsigned) sizeof(BUFFER)); /* Release buffer block */ bp = *top_buf; } return (TRUE); }
static void DeallocateFactBloadData( void *theEnv) { size_t space; int i; for (i = 0; i < FactBinaryData(theEnv)->NumberOfPatterns; i++) { DestroyAlphaMemory(theEnv,&FactBinaryData(theEnv)->FactPatternArray[i].header,FALSE); } space = FactBinaryData(theEnv)->NumberOfPatterns * sizeof(struct factPatternNode); if (space != 0) genfree(theEnv,(void *) FactBinaryData(theEnv)->FactPatternArray,space); }
/*************************************************************** 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; size_t space; space = (sizeof(DEFINSTANCES_MODULE) * DefinstancesBinaryData(theEnv)->ModuleCount); if (space == 0L) return; genfree(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 = (sizeof(DEFINSTANCES) * DefinstancesBinaryData(theEnv)->DefinstancesCount); if (space == 0L) return; genfree(theEnv,(void *) DefinstancesBinaryData(theEnv)->DefinstancesArray,space); DefinstancesBinaryData(theEnv)->DefinstancesArray = NULL; DefinstancesBinaryData(theEnv)->DefinstancesCount = 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; }
static void DeallocateDefgenericBinaryData( void *theEnv) { #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) size_t space; space = DefgenericBinaryData(theEnv)->GenericCount * sizeof(struct defgeneric); if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->DefgenericArray,space); space = DefgenericBinaryData(theEnv)->MethodCount * sizeof(struct method); if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->MethodArray,space); space = DefgenericBinaryData(theEnv)->RestrictionCount * sizeof(struct restriction); if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->RestrictionArray,space); space = DefgenericBinaryData(theEnv)->TypeCount * sizeof(void *); if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->TypeArray,space); space = DefgenericBinaryData(theEnv)->ModuleCount * sizeof(struct defgenericModule); if (space != 0) genfree(theEnv,(void *) DefgenericBinaryData(theEnv)->ModuleArray,space); #endif }
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 DeallocateDefglobalBloadData( void *theEnv, EXEC_STATUS) { #if (BLOAD || BLOAD_ONLY || BLOAD_AND_BSAVE) && (! RUN_TIME) size_t space; long i; for (i = 0; i < DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals; i++) { if (DefglobalBinaryData(theEnv,execStatus)->DefglobalArray[i].current.type == MULTIFIELD) { ReturnMultifield(theEnv,execStatus,(struct multifield *) DefglobalBinaryData(theEnv,execStatus)->DefglobalArray[i].current.value); } } space = DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobals * sizeof(struct defglobal); if (space != 0) { genfree(theEnv,execStatus,(void *) DefglobalBinaryData(theEnv,execStatus)->DefglobalArray,space); } space = DefglobalBinaryData(theEnv,execStatus)->NumberOfDefglobalModules * sizeof(struct defglobalModule); if (space != 0) { genfree(theEnv,execStatus,(void *) DefglobalBinaryData(theEnv,execStatus)->ModuleArray,space); } #endif }
static void DeallocateRouterData( void *theEnv) { struct router *tmpPtr, *nextPtr; tmpPtr = RouterData(theEnv)->ListOfRouters; while (tmpPtr != NULL) { nextPtr = tmpPtr->next; genfree(theEnv,tmpPtr->name,strlen(tmpPtr->name) + 1); rtn_struct(theEnv,router,tmpPtr); tmpPtr = nextPtr; } }
/************************************************************ NAME : BloadandRefresh DESCRIPTION : Loads and refreshes objects - will bload all objects at once, if possible, but will aslo work in increments if memory is restricted INPUTS : 1) the number of objects to bload and update 2) the size of one object 3) An update function which takes a bloaded object buffer and the index of the object to refresh as arguments RETURNS : Nothing useful SIDE EFFECTS : Objects bloaded and updated NOTES : Assumes binary file pointer is positioned for bloads of the objects ************************************************************/ globle void BloadandRefresh( void *theEnv, long objcnt, size_t objsz, void (*objupdate)(void *,void *,long)) { register long i,bi; char *buf; long objsmaxread,objsread; size_t space; int (*oldOutOfMemoryFunction)(void *,size_t); if (objcnt == 0L) return; oldOutOfMemoryFunction = EnvSetOutOfMemoryFunction(theEnv,BloadOutOfMemoryFunction); objsmaxread = objcnt; do { space = objsmaxread * objsz; buf = (char *) genalloc(theEnv,space); if (buf == NULL) { if ((objsmaxread / 2) == 0) { if ((*oldOutOfMemoryFunction)(theEnv,space) == TRUE) { EnvSetOutOfMemoryFunction(theEnv,oldOutOfMemoryFunction); return; } } else objsmaxread /= 2; } } while (buf == NULL); EnvSetOutOfMemoryFunction(theEnv,oldOutOfMemoryFunction); i = 0L; do { objsread = (objsmaxread > (objcnt - i)) ? (objcnt - i) : objsmaxread; GenReadBinary(theEnv,(void *) buf,objsread * objsz); for (bi = 0L ; bi < objsread ; bi++ , i++) (*objupdate)(theEnv,buf + objsz * bi,i); } while (i < objcnt); genfree(theEnv,(void *) buf,space); }