diff --git a/reactos/lib/atl/atlmem.h b/reactos/lib/atl/atlmem.h index cbab52ce979..580db031594 100644 --- a/reactos/lib/atl/atlmem.h +++ b/reactos/lib/atl/atlmem.h @@ -14,28 +14,28 @@ void *operator new (size_t, void *buf) namespace ATL { -interface DECLSPEC_UUID("654F7EF5-CFDF-4df9-A450-6C6A13C622C0") IAtlMemMgr; -// #undef INTERFACE -// #define INTERFACE IAtlMemMgr -DECLARE_INTERFACE(IAtlMemMgr) +//__interface __declspec(uuid("654F7EF5-CFDF-4df9-A450-6C6A13C622C0")) +class IAtlMemMgr { public: - _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Allocate( + virtual ~IAtlMemMgr() {}; + + virtual _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Allocate( _In_ size_t SizeBytes - ); + ) = 0; - void Free( + virtual void Free( _Inout_opt_ void* Buffer - ); + ) = 0; - _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Reallocate( + virtual _Ret_maybenull_ _Post_writable_byte_size_(SizeBytes) void* Reallocate( _Inout_updates_bytes_opt_(SizeBytes) void* Buffer, _In_ size_t SizeBytes - ); + ) = 0; - size_t GetSize( + virtual size_t GetSize( _In_ void* Buffer - ); + ) = 0; }; class CWin32Heap : public IAtlMemMgr @@ -74,10 +74,8 @@ public: { if (Buffer) { - BOOL FreeOk; - UNREFERENCED_PARAMETER(FreeOk); - FreeOk = ::HeapFree(m_hHeap, 0, Buffer); - ATLASSERT(FreeOk == TRUE); + if (!::HeapFree(m_hHeap, 0, Buffer)) + ATLASSERT(FALSE); } } diff --git a/reactos/lib/atl/atlsimpstr.h b/reactos/lib/atl/atlsimpstr.h index d9033ce0c3f..1c8828c7a4a 100644 --- a/reactos/lib/atl/atlsimpstr.h +++ b/reactos/lib/atl/atlsimpstr.h @@ -3,39 +3,39 @@ #pragma once -#include "atlcore.h" +#include namespace ATL { struct CStringData; -interface IAtlStringMgr; -// #undef INTERFACE -// #define INTERFACE IAtlStringMgr -DECLARE_INTERFACE(IAtlStringMgr) +// Pure virtual interface +class IAtlStringMgr { public: - _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) + virtual ~IAtlStringMgr() {} + + virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) CStringData* Allocate( _In_ int nAllocLength, _In_ int nCharSize - ); + ) = 0; - void Free( + virtual void Free( _Inout_ CStringData* pData - ); + ) = 0; virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + nAllocLength*nCharSize) CStringData* Reallocate( _Inout_ CStringData* pData, _In_ int nAllocLength, _In_ int nCharSize - ); + ) = 0; - CStringData* GetNilString(void); - IAtlStringMgr* Clone(void); + virtual CStringData* GetNilString(void) = 0; + virtual IAtlStringMgr* Clone(void) = 0; }; @@ -243,6 +243,11 @@ public: return m_pszData; } + _Ret_notnull_ _Post_writable_size_(nMinBufferLength + 1) PXSTR GetBuffer(_In_ int nMinBufferLength) + { + return PrepareWrite(nMinBufferLength); + } + int GetAllocLength() const throw() { return GetData()->nAllocLength; @@ -269,11 +274,6 @@ public: return (GetLength() == 0); } - _Ret_notnull_ _Post_writable_size_(nMinBufferLength + 1) PXSTR GetBuffer(_In_ int nMinBufferLength) - { - return PrepareWrite(nMinBufferLength); - } - CStringData* GetData() const throw() { return reinterpret_cast(m_pszData) - 1; @@ -405,16 +405,14 @@ private: else { pNewData = pNewStringMgr->Allocate(pData->nDataLength, sizeof(XCHAR)); - if (pNewData == NULL) - { - throw; // ThrowMemoryException(); - } + if (pNewData == NULL) throw; + pNewData->nDataLength = pData->nDataLength; CopyChars(PXSTR(pNewData->data()), pData->nDataLength + 1, PCXSTR(pData->data()), pData->nDataLength + 1); } - return( pNewData ); + return(pNewData); } }; diff --git a/reactos/lib/atl/atlstr.h b/reactos/lib/atl/atlstr.h index 4a851314bf3..d07f665ab59 100644 --- a/reactos/lib/atl/atlstr.h +++ b/reactos/lib/atl/atlstr.h @@ -73,7 +73,7 @@ public: nDataBytes = nChars * nCharSize; SizeBytes = sizeof(CStringData) + nDataBytes; - pNewData = static_cast< CStringData* >(m_MemMgr->Reallocate(StrData, SizeBytes)); + pNewData = static_cast(m_MemMgr->Reallocate(StrData, SizeBytes)); if (pNewData == NULL) return NULL; pNewData->nAllocLength = nChars - 1; @@ -97,43 +97,43 @@ private: } }; - -template> -class StrTraitATL : - public StringIterator -{ -public: - static HINSTANCE FindStringResourceInstance(_In_ UINT nID) throw() - { - return AtlFindStringResourceInstance(nID); - } - - static IAtlStringMgr* GetDefaultManager() throw() - { - return CAtlStringMgr::GetInstance(); - } -}; - - -template< typename _CharType = wchar_t> -class ChTraitsOS : - public ChTraitsBase<_CharType> -{ -protected: - -public: - -}; - -#ifndef _ATL_CSTRING_NO_CRT - typedef CStringT>> CAtlStringW; -#else - typedef CStringT> CAtlStringW; -#endif - -#ifndef _AFX - typedef CAtlStringW CStringW; -#endif +// +//template class > +//class StrTraitATL : +// public StringIterator +//{ +//public: +// static HINSTANCE FindStringResourceInstance(_In_ UINT nID) throw() +// { +// return AtlFindStringResourceInstance(nID); +// } +// +// static IAtlStringMgr* GetDefaultManager() throw() +// { +// return CAtlStringMgr::GetInstance(); +// } +//}; +// +// +//template< typename _CharType = wchar_t> +//class ChTraitsOS : +// public ChTraitsBase<_CharType> +//{ +//protected: +// +//public: +// +//}; +// +//#ifndef _ATL_CSTRING_NO_CRT +// typedef CStringT>> CAtlStringW; +//#else +// typedef CStringT> CAtlStringW; +//#endif +// +//#ifndef _AFX +// typedef CAtlStringW CStringW; +//#endif } //namespace ATL diff --git a/reactos/lib/atl/cstringt.h b/reactos/lib/atl/cstringt.h index 7683f725725..6c5174d8e2c 100644 --- a/reactos/lib/atl/cstringt.h +++ b/reactos/lib/atl/cstringt.h @@ -2,11 +2,11 @@ #define __CSTRINGT_H__ #pragma once +#include #include #include #include -#include "atlmem.h" -#include "atlsimpstr.h" +#include namespace ATL { @@ -90,8 +90,7 @@ public: static void __cdecl Construct(_In_ CStringT* pString) { - // new pString(CStringT); - new (pString) CStringT; + pString = new CStringT; } CStringT(_In_ const CStringT& strSrc) : @@ -112,9 +111,9 @@ public: if (pImage == NULL) return FALSE; int nLength = StringTraits::GetBaseTypeLength(pImage->achString, pImage->nLength); - PXSTR pszBuffer = GetBuffer(nLength); + PXSTR pszBuffer = CThisSimpleString::GetBuffer(nLength); StringTraits::ConvertToBaseType(pszBuffer, nLength, pImage->achString, pImage->nLength); - ReleaseBufferSetLength(nLength); + CThisSimpleString::ReleaseBufferSetLength(nLength); return TRUE; }