コード例 #1
0
ファイル: xsvector.c プロジェクト: loomplyty/IMU
//! \relates XsVector \brief Release and clear the contents of the vector
void XsVector_destruct(XsVector* thisPtr)
{
	if (thisPtr->m_data && (thisPtr->m_flags & XSDF_Managed))
	{
		// clear contents
		xsMathFree((void*) thisPtr->m_data);
		INC_FREE();
	}
	// init to 0
	if (!(thisPtr->m_flags & XSDF_FixedSize))
	{
		*((XsReal**) &thisPtr->m_data) = 0;
		*((XsSize*) &thisPtr->m_size) = 0;
		*((int*) &thisPtr->m_flags) = 0;
	}
	else
		*((int*) &thisPtr->m_flags) |= XSDF_Empty;
}
コード例 #2
0
ファイル: xsarray.c プロジェクト: Insomnia-/mrpt
/*! \relates XsArray
	\brief Clears and frees memory allocated by the XsArray
	\note After XsArray_destruct is called, the object is empty but valid,
	ie. it can be used as if XsArray_construct has been called on it.
*/
void XsArray_destruct(void* thisPtr)
{
	XsArray* thisArray = (XsArray*) thisPtr;
	if (thisArray->m_data && (thisArray->m_flags & XSDF_Managed))
	{
		XsSize i;
		// clear contents
		if (thisArray->m_descriptor->itemDestruct)
			for (i=0; i<thisArray->m_reserved; ++i)
				thisArray->m_descriptor->itemDestruct(elemAt(thisArray->m_data, i));
		free((void*) thisArray->m_data);
		INC_FREE();
	}
	// init to 0
	*((void**) &thisArray->m_data) = 0;
	*((XsSize*) &thisArray->m_size) = 0;
	*((XsSize*) &thisArray->m_reserved) = 0;
	*((int*) &thisArray->m_flags) = (thisArray->m_flags & (XSDF_Managed | XSDF_FixedSize));
}