Esempio n. 1
0
bool CDatum::CreateStringFromHandoff (CString &sString, CDatum *retDatum)

//	CreateStringFromHandoff
//
//	Creates a string by taking a handoff from a string

	{
	if (sString.IsLiteral())
		{
		if (sString.IsEmpty())
			retDatum->m_dwData = 0;
		else
			retDatum->m_dwData = (DWORD_PTR)(LPSTR)sString;
		}
	else
		{
		//	Take ownership of the data

		LPSTR pString = sString.Handoff();

		//	Track it with our allocator (but only if not NULL).
		//	(If pString is NULL then this is represented as Nil).

		if (pString)
			g_StringAlloc.New(pString);

		//	Store the pointer

		retDatum->m_dwData = (DWORD_PTR)pString;
		}

	//	Done

	return true;
	}
Esempio n. 2
0
CDatum::CDatum (const CString &sString)

//	CDatum constructor

	{
	//	If this is a literal string, then we can just
	//	take the value, because it doesn't need to be freed.
	//	NOTE: We can only do this if the literal pointer is
	//	DWORD aligned.

	if (sString.IsLiteral())
		{
		if (sString.IsEmpty())
			{
			m_dwData = 0;
			return;
			}
		else
			{
			m_dwData = (DWORD_PTR)(LPSTR)sString;
			if ((m_dwData & AEON_TYPE_MASK) == AEON_TYPE_STRING)
				return;

#ifdef DEBUG
			else
				g_iUnalignedLiteralCount++;
#endif
			}
		}

	//	Get a copy of the naked LPSTR out of the string

	CString sNewString(sString);
	LPSTR pString = sNewString.Handoff();

	//	Track it with our allocator (but only if not NULL).
	//	(If pString is NULL then this is represented as Nil).

	if (pString)
		g_StringAlloc.New(pString);

	//	Store the pointer

	m_dwData = (DWORD_PTR)pString;

	//	No need to mark the type (because TYPE_STRING is 0)

	ASSERT(AEON_TYPE_STRING == 0x00);
	}