default allocator, overriding @ runtime

Trey Jackson tjackson@ichips.intel.com
Thu Feb 12 02:25:00 GMT 2004


Benjamin wrote:
 >>The question I have is, is it possible to override/replace the default
 >>allocator with my_favorite_allocator at runtime?
 >
 >No. Although it seems like a fun thing to do, I (and others) cannot seem
 >to find a way to do this an still have inter-operability.

A related question:

Some people want to use a different allocator (by default) for all of
stl.  I'd still like to be able to turn it off at runtime.

Is the best/only way to replace the default allocator to muck with 

    libstdc++-v3/include/bits/stl_alloc.h

And just change the code?
Then the run-time disabling would still work (provided we didn't mess
up the code:

,----------------
| 	    if (getenv("GLIBCPP_FORCE_NEW"))
| 	      __atomic_add(&_S_force_new, 1);
| 	    else
| 	      __atomic_add(&_S_force_new, -1);
`----------------



TJ

-- 
Trey Jackson
tjackson@ichips.intel.com

"The wide world is all about you:
 you can fence [yourself] in,
 but you cannot for ever fence it out."
-- Gildor, "Lord of the Rings"



More information about the Libstdc++ mailing list