// Filename: pallocator.h // Created by: drose (05Jun01) // //////////////////////////////////////////////////////////////////// // // PANDA 3D SOFTWARE // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved // // All use of this software is subject to the terms of the Panda 3d // Software license. You should have received a copy of this license // along with this source code; you will also find a current copy of // the license at http://www.panda3d.org/license.txt . // // To contact the maintainers of this program write to // panda3d@yahoogroups.com . // //////////////////////////////////////////////////////////////////// #ifndef PALLOCATOR_H #define PALLOCATOR_H #include #include "dtoolbase.h" //////////////////////////////////////////////////////////////////// // Class : pallocator // Description : This is our own Panda specialization on the default // STL allocator. Its main purpose is to call the hooks // for MemoryUsage to properly track STL-allocated // memory. // // pvector, pmap, etc. are all defined in this directory // to use a pallocator. //////////////////////////////////////////////////////////////////// #if defined(UNKNOWN_ALLOCATOR) #define pallocator allocator #elif defined(OLD_STYLE_ALLOCATOR) // Early versions of gcc wanted to use its own kind of allocator, // somewhat different from the STL standard. Irix uses this one too. // It might be inherited from an early draft of the STL standard. template class pallocator : public alloc { public: #ifndef NDEBUG INLINE static Type *allocate(size_t n); INLINE static void deallocate(void *p, size_t n); #endif // NDEBUG }; #elif defined(GNU_STYLE_ALLOCATOR) // Later versions of gcc want to use a still different, nonstandard // definition. Sheesh. template class pallocator : public allocator { public: INLINE pallocator(); template INLINE pallocator(const pallocator<_Tp1> &other); #ifndef NDEBUG INLINE Type *allocate(size_t n); INLINE void deallocate(void *p, size_t n); #endif // NDEBUG template struct rebind { typedef pallocator<_Tp1> other; }; }; #else // *_STYLE_ALLOCATOR // This is the correct allocator declaration as the current C++ // standard defines it. template class pallocator : public allocator { public: #ifndef NDEBUG INLINE pointer allocate(size_type n, allocator::const_pointer hint = 0); INLINE void deallocate(void *p, size_type n); #endif // NDEBUG }; #endif // *_STYLE_ALLOCATOR #if !defined(UNKNOWN_ALLOCATOR) #include "pallocator.T" #endif #endif