I'm working with a system which has its own memory manager. Any class
which uses the system defines operator new and operator delete in the
following way:
void* operator new(size_t size) {return(memMgr.allocate(size));}
void operator delete(void *p) {memMgr.free(p);}
Here memMgr is some global object which does all the behind-the-scenes
work, taking care of things like memory pools, disk swapping certain
objects, etc.
What I'd like to do is make STL classes use this same underlying memory
manager. If I understand things right, this means I need to basically
build an Allocator which will call these memMgr.allocate and memMgr.free
fcns. (Unbelievably, nobody using this system uses STL classes so this
issue has never previously arisen.)
I'm looking for suggestions on where to find sample code implementing
STL allocators and also any general advice on undertaking this,
especially if there are any critical issues that make this idea
impossible. My naive feeling is that this shouldn't be very hard, since
the Allocator doesn't really do much except forward a couple calls, and
yet having never written an Allocator I'm a little overwhelemed by the
details in TC++PL.
Thanks for your help,
Mark