global new operator issue
-
I'm trying to override the global new operator:
void* __cdecl ::operator new(size_t nSize)
{
...
}It is called for almost all cases. However in case of std::string allocation it does not work. The internal allocator of the std::string object still calls the default (CRT) global new allocator. Any idea why? Thanks, Abyss
-
I'm trying to override the global new operator:
void* __cdecl ::operator new(size_t nSize)
{
...
}It is called for almost all cases. However in case of std::string allocation it does not work. The internal allocator of the std::string object still calls the default (CRT) global new allocator. Any idea why? Thanks, Abyss
Maybe the STL authors want to control the allocation process just as you are trying to do. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Maybe the STL authors want to control the allocation process just as you are trying to do. :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Not sure, because for std::vector my new operator is called. And in some cases for the std::string too. In the particular case the given std::string calls my new operator, however my delete operator is not called. This of course is toxic, because the default CRT delete tries to release my pointer and the application crashes. My delete operator is defined as: void __cdecl ::operator delete(void* ptr) { ... } Not sure what is wrong here... Thanks, Abyss
-
Not sure, because for std::vector my new operator is called. And in some cases for the std::string too. In the particular case the given std::string calls my new operator, however my delete operator is not called. This of course is toxic, because the default CRT delete tries to release my pointer and the application crashes. My delete operator is defined as: void __cdecl ::operator delete(void* ptr) { ... } Not sure what is wrong here... Thanks, Abyss
You do know you have the ultimate documentation, don't you? :) (That would be the source code)
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
You do know you have the ultimate documentation, don't you? :) (That would be the source code)
Mark Salsbery Microsoft MVP - Visual C++ :java:
:)
Bram van Kampen
-
You do know you have the ultimate documentation, don't you? :) (That would be the source code)
Mark Salsbery Microsoft MVP - Visual C++ :java:
-
It means: You designed the Software, and You wrote the Code, so You are the best person in the world to know what's it supposed to do or not do in the firstplace. None of us are in that priviledged position. :)
Bram van Kampen