Skip to content

Commit

Permalink
Add operator overloads for C++14 delete
Browse files Browse the repository at this point in the history
  • Loading branch information
xezon committed Sep 19, 2024
1 parent 8a23e36 commit bd4c2e2
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/game/common/system/gamememory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ void *operator new[](size_t bytes)
return g_dynamicMemoryAllocator->Allocate_Bytes(bytes);
}

void operator delete(void *ptr)
void operator delete(void *ptr) noexcept
{
++g_theLinkChecker;
Init_Memory_Manager_Pre_Main();
Expand All @@ -204,11 +204,23 @@ void operator delete(void *ptr)
g_dynamicMemoryAllocator->Free_Bytes(ptr);
}

void operator delete[](void *ptr)
void operator delete[](void *ptr) noexcept
{
++g_theLinkChecker;
Init_Memory_Manager_Pre_Main();
captainslog_dbgassert(g_dynamicMemoryAllocator, "must init memory manager before calling global operator delete");

g_dynamicMemoryAllocator->Free_Bytes(ptr);
}

//#if __cplusplus >= 201402L
void operator delete(void *ptr, size_t sz) noexcept
{
operator delete(ptr);
}

void operator delete[](void *ptr, size_t sz) noexcept
{
operator delete[](ptr);
}
//#endif

0 comments on commit bd4c2e2

Please sign in to comment.