예제 #1
0
/* ---------------------------------------------------------------------------------
*  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;
}
예제 #2
0
파일: LArray.c 프로젝트: dgu123/dc-lib
LArray* LArray_NewFromData(ui4 inItemSize, void** inDataA, ui4 inDataSize) {

    LArray theObject;

    /* Set item size and number of items */
    if (inItemSize<1 || inDataSize%inItemSize) Throw(LArray_INVALID_SIZE);

    theObject.mItemSize      = inItemSize;
    theObject.mItemsCount    = inDataSize/inItemSize;
    
    /* Added IF 021112 */
    theObject.mSyncData      = NULL;

    /* Set data segment */
    theObject.mData = (i1*)*inDataA;

    /* Flag block is now incorporated into newly created LArray */
    (*inDataA) = NULL;

    /* Set array size */
    theObject.mDataSize = inDataSize;

    #ifdef TRACE_OPERATIONS_
        LSystem_Print("LArray_Constructor [itemsize=%u  datasize=%u]\n",
                      inItemSize,inDataSize);
    #endif

    return LMemory_NewObject(LArray,theObject);
}
예제 #3
0
파일: LQuickFind.c 프로젝트: dgu123/dc-lib
LQuickFind* LQuickFind_New () 
{
	LQuickFind theObject={0};
	
	//creates hash table...
	theObject.mHashTable=LHash_New ();
	
#if LQuickFind_STATS
	/*resets stats...*/
	theObject.mNumUnions=0;
    	theObject.mItemsMovedByUnions=0;
    	theObject.mNumFinds=0;
#endif
    
	return LMemory_NewObject (LQuickFind, theObject);
}
예제 #4
0
파일: LArray.c 프로젝트: dgu123/dc-lib
LArray* LArray_New(ui4 inItemSize) {

    LArray theObject;

    if (inItemSize<1) Throw(LArray_INVALID_SIZE);

    theObject.mData          = NULL;
    theObject.mDataSize      = 0;
    theObject.mItemsCount    = 0;
    theObject.mItemSize      = inItemSize;
    theObject.mSyncData      = NULL;

    #ifdef TRACE_OPERATIONS_
        LSystem_Print("LArray_Constructor [itemsize=%u]\n", inItemSize);
    #endif

    return LMemory_NewObject(LArray,theObject);
}