// Filename: pallocator.T // 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 . // //////////////////////////////////////////////////////////////////// template INLINE pallocator_single:: pallocator_single() throw() { } template INLINE TYPENAME pallocator_single::pointer pallocator_single:: allocate(TYPENAME pallocator_single::size_type n, TYPENAME allocator::const_pointer) { TAU_PROFILE("pallocator_single:allocate()", " ", TAU_USER); // This doesn't support allocating arrays. assert(n == 1); return DeletedChain::allocate(sizeof(Type)); } template INLINE void pallocator_single:: deallocate(TYPENAME pallocator_single::pointer p, TYPENAME pallocator_single::size_type) { TAU_PROFILE("pallocator_single:deallocate()", " ", TAU_USER); return DeletedChain::deallocate(p); } template INLINE pallocator_array:: pallocator_array() throw() { } template INLINE TYPENAME pallocator_array::pointer pallocator_array:: allocate(TYPENAME pallocator_array::size_type n, TYPENAME allocator::const_pointer) { TAU_PROFILE("pallocator_array:allocate()", " ", TAU_USER); #ifdef DO_MEMORY_USAGE return (TYPENAME pallocator_array::pointer)(*global_operator_new)(n * sizeof(Type)); #else return (TYPENAME pallocator_array::pointer)malloc(n * sizeof(Type)); #endif // DO_MEMORY_USAGE } template INLINE void pallocator_array:: deallocate(TYPENAME pallocator_array::pointer p, TYPENAME pallocator_array::size_type) { TAU_PROFILE("pallocator_array:deallocate()", " ", TAU_USER); #ifdef DO_MEMORY_USAGE (*global_operator_delete)(p); #else free(p); #endif // DO_MEMORY_USAGE }