Re: STL with Performer/Vega

New Message Reply Date view Thread view Subject view Author view

dgray7++at++csc.com
Wed, 7 Apr 1999 13:09:01 +1000


I've used the following allocator successfully with the current SGI STL:

  #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.


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Wed Apr 07 1999 - 04:40:43 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.