コード例 #1
0
ファイル: LArray.c プロジェクト: dgu123/dc-lib
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;
}
コード例 #2
0
ファイル: LEdgeInfo.c プロジェクト: coder-chenzhi/aprof
/* ---------------------------------------------------------------------------------
*  _LEdgeInfo_DeleteItemAt
*  ---------------------------------------------------------------------------------
*  Delete the info of a specified Edge*/
void _LEdgeInfo_DeleteItemAt(LEdgeInfo* This, LGraph_TEdge* inEdge) 
{
	LException* theException;
	ui4 theIndex;

    if (This == NULL) Throw(LEdgeInfo_OBJECT_NULL_POINTER);

	/* if installed, calls the destructor handler */
	if (This->mDealloc)
		(*(This->mDealloc))(This, inEdge);

	theIndex = inEdge->mIndex;
    LMemory_Copy(LArray_LastItem(This->mData),
                  LArray_ItemAt(This->mData, theIndex),
                  LArray_GetItemSize(This->mData));
	Try
		LArray_ResizeBy(This->mData, -1);
	Catch(theException)
		LException_Dump(theException);
}
コード例 #3
0
ファイル: LEdgeInfo.c プロジェクト: coder-chenzhi/aprof
/* ---------------------------------------------------------------------------------
*  LEdgeInfo_AssignItemAt
*  ---------------------------------------------------------------------------------
*  Assigns the data pointed by inItem to the Edge inEdge */
void LEdgeInfo_AssignItemAt(LEdgeInfo* This, LGraph_TEdge* inEdge, const void* inItem)
{ /*at this point there MUST be the allocated space for the item */
	LException* theException;
	void* thePtr;
	ui4   theItemSize;

    if (This == NULL) Throw(LEdgeInfo_OBJECT_NULL_POINTER);
    if (inEdge == NULL) Throw(LEdgeInfo_EDGE_NULL_POINTER);
    if (inItem == NULL) Throw(LEdgeInfo_ITEM_NULL_POINTER);

	Try
	{
		thePtr = LArray_ItemAt(This->mData, inEdge->mIndex);
		theItemSize = LArray_GetItemSize(This->mData);
	}
	Catch(theException)
		LException_Dump(theException);

	LMemory_Copy(inItem, thePtr, theItemSize);
}