// ---------------------------------------------------------------------------------
// new.
inline void* __cdecl operator new(size_t size)
{
char* pt = typebuff;
size_t sizeS = ARRAYSIZE(typebuff);
size_t n = 0;
void* p = malloc(size);
n = SimpleRs::addr2asc(pt, sizeS, " p=0x", p);
pt += n; sizeS -= n;
#ifdef _M_IX86
n = SimpleRs::dword2dec (pt, sizeS, " size=", size);
#endif
#ifdef _M_AMD64
n = SimpleRs::qword2asc (pt, sizeS, " size=0x", (unsigned long long )size);
#endif
::OutputDebugStringA(typebuff);
return p;
}
// ---------------------------------------------------------------------------------
// delete.
inline void __cdecl operator delete(void *p)
{
free (p);
}
// ---------------------------------------------------------------------------------
int __cdecl _tmain(int argc, TCHAR **argv)
{
::OutputDebugString(_T("----- vvv -----"));
#ifdef _M_IX86
size_t v1 = 2;
#endif
#ifdef _M_AMD64
size_t v1 = 5;
#endif
size_t v2 = 1024;
size_t total = v1;
total *= v2;
total *= v2;
total *= v2;
char *ptr = NULL;
ptr = new char[total];
ptr[0] = 'a';
ptr[total - 1] = 'z';
std::cout << sizeof(size_t) << '\t' << reinterpret_cast(ptr) << '\n' << ptr[0] << ptr[total - 1] << std::endl;
delete[] ptr;
::OutputDebugString(_T("----- ^^^ -----"));
}