Compare commits

...

2 Commits

Author SHA1 Message Date
Mark Jansen
fa677acabf [SDK] Disable gcc threadsafe static init code. #79 2017-12-28 13:22:01 +01:00
Timo Kreuzer
8a86a4e952 [SDK] Initialize Atl string manager in a threadsafe way. #79 2017-12-28 13:22:01 +01:00
2 changed files with 22 additions and 4 deletions

View File

@@ -72,7 +72,7 @@ if(DBG)
add_compile_flags_language("-Wdeclaration-after-statement" "C")
endif()
add_compile_flags_language("-fno-rtti -fno-exceptions" "CXX")
add_compile_flags_language("-fno-rtti -fno-exceptions -fno-threadsafe-statics" "CXX")
#bug
#file(TO_NATIVE_PATH ${REACTOS_SOURCE_DIR} REACTOS_SOURCE_DIR_NATIVE)

View File

@@ -27,9 +27,27 @@ public:
static IAtlStringMgr* GetInstance(void)
{
static CWin32Heap Win32Heap(::GetProcessHeap());
static CAtlStringMgr StringMgr(&Win32Heap);
return &StringMgr;
static CWin32Heap* s_Win32Heap = NULL;
static IAtlStringMgr* s_StringMgr;
if (s_Win32Heap == NULL)
{
CWin32Heap* Win32Heap = new CWin32Heap(::GetProcessHeap());
if (InterlockedCompareExchangePointer((PVOID*)&s_Win32Heap, Win32Heap, NULL) != NULL)
{
delete Win32Heap;
}
}
if (s_StringMgr == NULL)
{
IAtlStringMgr* StringMgr = new CAtlStringMgr(s_Win32Heap);
if (InterlockedCompareExchangePointer((PVOID*)&s_StringMgr, StringMgr, NULL) != NULL)
{
delete StringMgr;
}
}
return s_StringMgr;
}
virtual _Ret_maybenull_ _Post_writable_byte_size_(sizeof(CStringData) + NumChars * CharSize) CStringData* Allocate(