mirror of
https://github.com/Mauler125/r5sdk.git
synced 2025-02-09 19:15:03 +01:00
Tier0: make sure the memalloc singleton initializer is thread safe
Only enter code if the atomic exchange was performed.
This commit is contained in:
parent
716a3efa0c
commit
6827d1ed02
@ -13,20 +13,19 @@
|
|||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
// Purpose: initialize the global memory allocator singleton pointer
|
// Purpose: initialize the global memory allocator singleton pointer
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
static bool s_bAllocatorInitialized = false;
|
static std::atomic_bool s_bAllocatorInitialized = false;
|
||||||
static void InitAllocator()
|
static void InitAllocator()
|
||||||
{
|
{
|
||||||
if (!s_bAllocatorInitialized)
|
if (s_bAllocatorInitialized.exchange(true))
|
||||||
{
|
return;
|
||||||
s_bAllocatorInitialized = true;
|
|
||||||
const QWORD imageBase = CModule::GetProcessEnvironmentBlock()->ImageBaseAddress;
|
|
||||||
|
|
||||||
CreateGlobalMemAlloc = CModule::GetExportedSymbol(imageBase,
|
const QWORD imageBase = CModule::GetProcessEnvironmentBlock()->ImageBaseAddress;
|
||||||
"CreateGlobalMemAlloc").RCast<CStdMemAlloc* (*)(void)>();
|
|
||||||
|
|
||||||
g_pMemAllocSingleton = CModule::GetExportedSymbol(imageBase,
|
CreateGlobalMemAlloc = CModule::GetExportedSymbol(imageBase,
|
||||||
"g_pMemAllocSingleton").DerefSelf().RCast<CStdMemAlloc*>();
|
"CreateGlobalMemAlloc").RCast<CStdMemAlloc * (*)(void)>();
|
||||||
}
|
|
||||||
|
g_pMemAllocSingleton = CModule::GetExportedSymbol(imageBase,
|
||||||
|
"g_pMemAllocSingleton").DerefSelf().RCast<CStdMemAlloc*>();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user