G
Guest
Hi all,
I am wanting to write a memory allocation statistic gathering wrapper and
here is a basic bit of code that I wrote to back it up:
class CMemoryManager
{
public:
static void* operator new(size_t AllocationSize)
{
++m_NumberOfAllocations;
return :perator new(AllocationSize);
}
static int m_NumberOfAllocations;
};
int CMemoryManager::NumberOfAllocations = 0;
void* operator new(size_t AllocationSize)
{
return CMemoryManager:perator new(AllocationSize);
}
int main()
{
int* pInt = new int;
return 0;
}
now this all compiles just fine, but my call to :perator new inside
CMemoryManager resolves back to my overridden operator new rather than the
intrinsic global new.
I really don't want to force client code to use some specially named version
of new or something with some bogo parameters but it is looking like that is
impossible unless I convert my memory manager to use malloc internally or
spomething. Any ideas?
I am wanting to write a memory allocation statistic gathering wrapper and
here is a basic bit of code that I wrote to back it up:
class CMemoryManager
{
public:
static void* operator new(size_t AllocationSize)
{
++m_NumberOfAllocations;
return :perator new(AllocationSize);
}
static int m_NumberOfAllocations;
};
int CMemoryManager::NumberOfAllocations = 0;
void* operator new(size_t AllocationSize)
{
return CMemoryManager:perator new(AllocationSize);
}
int main()
{
int* pInt = new int;
return 0;
}
now this all compiles just fine, but my call to :perator new inside
CMemoryManager resolves back to my overridden operator new rather than the
intrinsic global new.
I really don't want to force client code to use some specially named version
of new or something with some bogo parameters but it is looking like that is
impossible unless I convert my memory manager to use malloc internally or
spomething. Any ideas?