So I have this memory tracer I wrote a while back which has worked perfectly since then.
It works by overwriting new, delete, malloc, etc and a static manager class will keep track of everything
Basically like this:
void* operator new (Core::uintp a_Size, const Core::char8* a_File, Core::uint32 a_Line);
void* operator new[] (Core::uintp a_Size, const Core::char8* a_File, Core::uint32 a_Line);
void operator delete (void *a_Memory, const Core::char8* a_File, Core::uint32 a_Line);
void operator delete[] (void *a_Memory, const Core::char8* a_File, Core::uint32 a_Line);
void operator delete (void *a_Memory);
void operator delete[] (void *a_Memory);
#define malloc(a_Size) MemoryTracer::Malloc(a_Size, __FILE__, __LINE__)
#define realloc(a_Memory, a_Size) MemoryTracer::Realloc(a_Memory, a_Size, __FILE__, __LINE__)
#define calloc(a_Count, a_Size) MemoryTracer::Calloc(a_Count, a_Size, __FILE__, __LINE__)
#define free(a_Memory) MemoryTracer::Free(a_Memory, __FILE__, __LINE__)
#define new new(__FILE__, __LINE__)
#define delete MemoryTracer::SetFreeInfo(__FILE__, __LINE__), delete
This worked fine for pretty much everything, until now.
I am currently writing a container class which has to use placement new.
The #define new new(__FILE__, __LINE__) messes up the placement new syntax.
Another problem is that placement new cannot be overwritten.
I am not sure what the best solution is for this problem, so I was hoping you guys could give me some suggestions.
Since the placement new doesn't allocate any memory, the solution does not have to involve the memory tracer.
I just want to keep the syntax as close to normal C++ as possible.