KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
Suppose I need to overload global ::operator new() for storing extra data with each allocated object . So basically it would work this way: for each call to global ::operator new() it will take the object size passed and add the size of extra data it will allocate a memory block of size deduced at previous step it will offset the pointer to the part of the block not occupied with extra data and return that offset value to the caller ::operator delete() will do the same in reverse - shift the pointer, access extra data, deallocate memory. Now the question is how do I allocate memory ? Of course I can call malloc() or some platform-specific function (that's how it is usually done). But normally when I need to allocate raw memory in C++ I call ::operator new() . Can I call the original ::operator new() to do the memory allocation from inside my overloaded global ::operator new() ?
Tags (comma-separated)
Save Edits
Cancel