OK, so next step is to use placement new. I'm not sure on how to use it. I've never done it before.
I've done a very simple test to get the hang of it:
Initiated by:Code:void* __cdecl operator new(std::size_t size, LPCSTR strLine, int nLine) { //::operator new(size, strLine, nLine); New::CMemoryRange* p = (New::CMemoryRange*)VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); new (p) New::CMemoryRange; return 0; }
Is this the right way to use placement new? Because all I get is:Code:new New::CMemoryRange;
In essence, it does nothing but return the same argument I passed in!Code:inline void *__CRTDECL operator new(size_t, void *_Where) {return (_Where); }
The basic idea here is to allocate memory using VirtualAlloc, then use placement new to actually construct the object, but I'm not sure how to do it.



LinkBack URL
About LinkBacks




CornedBee