/* --------------------------------------------------------------------------------- * LEdgeInfo_NewCustom * --------------------------------------------------------------------------------- * Constructor for a user defined type */ LEdgeInfo* LEdgeInfo_NewCustom(LGraph* inGraph, ui4 inItemSize) { LEdgeInfo theObject = {0}; LEdgeInfo* theEdgeInfo = NULL; ui4 theCount; LException* theException; if (inGraph == NULL) Throw(LEdgeInfo_GRAPH_NULL_POINTER); Try { theObject.mData = LArray_New(inItemSize); theObject.mGraph = inGraph; theEdgeInfo = LMemory_NewObject(LEdgeInfo, theObject); theCount = LGraph_GetEdgesCount(inGraph); LArray_ResizeBy(theEdgeInfo->mData, theCount); theEdgeInfo->mGraphIdx = _LGraph_RegisterEdgeInfo(theEdgeInfo->mGraph, theEdgeInfo); } Catch(theException) {/* if something goes wrong, do cleanup */ LException_Dump(theException); if ( theEdgeInfo != NULL ) { if ( theEdgeInfo->mData != NULL ) LArray_Delete( &(theEdgeInfo->mData) ); LMemory_DeleteObject(&theEdgeInfo); } } return theEdgeInfo; }
/* --------------------------------------------------------------------------------- * OpenBlock * --------------------------------------------------------------------------------- */ void LSystem_OpenBlock(){ _TStackEntry theEntry = { 0 }; Try { if (sStack==NULL) sStack = LArray_New(sizeof(_TStackEntry)); theEntry.mPrintH = sPrintH; theEntry.mBlock = LArray_New(1); LArray_AppendItem(sStack,&theEntry); sPrintH = (LSystem_THandler)_PrintH; } CatchAny { if (theEntry.mBlock!=NULL) LArray_Delete(&theEntry.mBlock); if (sStack!=NULL && LArray_GetItemsCount(sStack)==0) LArray_Delete(&sStack); Rethrow; } }
LArray* LArray_Clone(LArray* This){ LArray* theArray; ui4 theDataSize; void* theData; theDataSize = LArray_GetDataSize(This); if (theDataSize) { theData = LMemory_Malloc(theDataSize); LMemory_Copy(LArray_GetData(This), theData, theDataSize); theArray = LArray_NewFromData(LArray_GetItemSize(This), &theData, theDataSize); } else theArray = LArray_New(LArray_GetItemSize(This)); return theArray; }
/* --------------------------------------------------------------------------------- * LQuickFind_MakeSet * --------------------------------------------------------------------------------- * MakeSet */ void LQuickFind_MakeSet (LQuickFind* This, ui4 inItem) { LArray* theNewTree; /*parameter checking...*/ if (inItem==LQuickFind_BAD_ITEM) return; /*if set already exists...*/ if (LQuickFind_Find (This, inItem)!=LQuickFind_BAD_ITEM) return; /*does nothing!*/ /*creates new 1-level tree...size of each leaf is 4 bytes...*/ theNewTree=LArray_New (4); /*inserts first item in new tree (this also identifies the tree)...*/ LArray_AppendItem (theNewTree, &inItem); /*inserts pointer to tree (LArray) into hash table (key = node id)*/ LHash_InsertItem (This->mHashTable, (void *)theNewTree, inItem); }