using STL with memory managed code
I'm using a game engine that supplies overrides of the C++ allocation operators.
I verified in my debugger that the linker is linking external libraries' calls to allocation operators to the overrides, instead of the standard implementation.
Is this going to be a problem? I'm more worried about data corruption and weird side effects than I am about performance.
You can provide all of the STL container your own custom allocator. Just write one that uses your overrides and you'll be fine. You might be fine anyway if your override declaration occurs before the inclusion of the STL class; your own custom allocator would probably be safer
-me
-me
can you go into more depth about "safer"?
my niave hunch is that i can break this fancy STL impl stuff easily, but I have no idea how or why.
my niave hunch is that i can break this fancy STL impl stuff easily, but I have no idea how or why.
You can always write some sample code using the custom memory management and then check it with valgrind (or similar tool) to see if there are any memory leaks or mismatched new-deletes/malloc-frees.
However I would personally avoid "overriding" STL allocators, unless I really what I was doing. Besides global new/delete operators are often overloaded for debugging/logging purposes and this would be probably pointless with STL. It would just pollute your logs needlessly, since we don't suspect our STL implementations from beaing leaky, do we?
However I would personally avoid "overriding" STL allocators, unless I really what I was doing. Besides global new/delete operators are often overloaded for debugging/logging purposes and this would be probably pointless with STL. It would just pollute your logs needlessly, since we don't suspect our STL implementations from beaing leaky, do we?
I too second the write test code to verify, this is ALWAYS a good idea and never hurts.
Also, its not the STL anymore unless you're using a very old compiler, it's now the SC++L, short for Standard C++ Library.
Also, its not the STL anymore unless you're using a very old compiler, it's now the SC++L, short for Standard C++ Library.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement