dgray7++at++csc.com
Wed, 7 Apr 1999 13:09:01 +1000
#include <Performer/pr/pfMemory.h>
class myAlloc
{
public:
static void* allocate( size_t size ) { return pfMemory::malloc( size
); }
static void* reallocate( void* memory, size_t, size_t size ) { return
pfMemory::realloc( memory, size ); }
static void deallocate( void* memory, size_t ) { pfMemory::free(
memory ); }
};
I simply copied from the form of the SGI-supplied default allocator (see
/usr/include/CC/alloc.h). This seems to be adequate for basic_strings,
vectors, hash_maps and multimaps - they're the ones I've actually used. I
don't think any of these containers actually use the reallocate() member,
so you could probably remove it.
If you're going to use STL for a real-time application, make sure you're
aware of the performance implications of everything that you do. There are
some things that you can do at configuration time to make the run-time code
faster and more deterministic, for example, reserving space in vectors
when you know the largest size beforehand.
David.
This archive was generated by hypermail 2.0b2 on Wed Apr 07 1999 - 04:40:43 PDT