void LArray_Delete(LArray** ThisA){ if ((*ThisA)->mData!=NULL) { LMemory_Free(&(*ThisA)->mData); if ((*ThisA)->mSyncData) *(*ThisA)->mSyncData = (*ThisA)->mData; } LMemory_DeleteObject(ThisA); }
/* --------------------------------------------------------------------------------- * 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; }
/* --------------------------------------------------------------------------------- * LEdgeInfo_Delete * --------------------------------------------------------------------------------- * Destructor */ void LEdgeInfo_Delete(LEdgeInfo** ThisA) { LException* theException; if (ThisA == NULL) Throw(LEdgeInfo_OBJECT_NULL_POINTER); if ((*ThisA) == NULL) Throw(LEdgeInfo_OBJECT_NULL_POINTER); _LEdgeInfo_CallItemsDestructor((*ThisA)); Try LArray_Delete( &( (*ThisA)->mData ) ); Catch(theException) LException_Dump(theException); LMemory_DeleteObject(ThisA); }
void LQuickFind_Delete (LQuickFind** ThisA) { LArray* theItems; ui4 theNumItems; ui4 i; LArray** theTreePtr; LHash* theTmpHashTable; /*creates tmp hash table...*/ theTmpHashTable=LHash_New (); /*retrieves pointers to all trees (larrays)...*/ theItems=LHash_GetAllItems ((*ThisA)->mHashTable); /*deletes all larrays...*/ theNumItems=LArray_GetItemsCount (theItems); for (i=0; i<theNumItems; i++) { /*retrieves pointer to tree...*/ theTreePtr=(LArray **)LArray_ItemAt (theItems, i); /*if not in tmp hash table...*/ if (!LHash_IsInTable (theTmpHashTable, (ui4)*theTreePtr)) { /*insert in tmp hash table...*/ LHash_InsertItem (theTmpHashTable, NULL, (ui4)*theTreePtr); /*delete tree...*/ LArray_Delete (theTreePtr); } } /*deletes tmp hash table...*/ LHash_Delete (&theTmpHashTable); /*must be manually deleted...*/ LArray_Delete (&theItems); /*deletes hash table...*/ LHash_Delete (&((*ThisA)->mHashTable)); /*deletes object...*/ LMemory_DeleteObject (ThisA); }