This commit is contained in:
David Rose 2001-06-06 16:39:43 +00:00
parent c538051c05
commit 08ddb0c4aa
2 changed files with 120 additions and 120 deletions

View File

@ -1,52 +1,52 @@
// Filename: dallocator.T // Filename: dallocator.T
// Created by: drose (05Jun01) // Created by: drose (05Jun01)
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
// PANDA 3D SOFTWARE // PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
// //
// All use of this software is subject to the terms of the Panda 3d // 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 // Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of // along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt . // the license at http://www.panda3d.org/license.txt .
// //
// To contact the maintainers of this program write to // To contact the maintainers of this program write to
// panda3d@yahoogroups.com . // panda3d@yahoogroups.com .
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifdef GCC_STYLE_ALLOCATOR #ifdef GCC_STYLE_ALLOCATOR
#ifndef NDEBUG #ifndef NDEBUG
template<class Type> template<class Type>
INLINE void *dallocator<Type>:: INLINE void *dallocator<Type>::
allocate(size_t n) { allocate(size_t n) {
return default_operator_new(n); return default_operator_new(n);
} }
template<class Type> template<class Type>
INLINE void dallocator<Type>:: INLINE void dallocator<Type>::
deallocate(void *p, size_t) { deallocate(void *p, size_t) {
default_operator_delete(p); default_operator_delete(p);
} }
#endif // NDEBUG #endif // NDEBUG
#else // GCC_STYLE_ALLOCATOR #else // GCC_STYLE_ALLOCATOR
#ifndef NDEBUG #ifndef NDEBUG
template<class Type> template<class Type>
INLINE dallocator<Type>::pointer dallocator<Type>:: INLINE dallocator<Type>::pointer dallocator<Type>::
allocate(dallocator<Type>::size_type n, allocator<void>::const_pointer) { allocate(dallocator<Type>::size_type n, allocator<void>::const_pointer) {
return (dallocator<Type>::pointer)default_operator_new(n * sizeof(Type)); return (dallocator<Type>::pointer)default_operator_new(n * sizeof(Type));
} }
template<class Type> template<class Type>
INLINE void dallocator<Type>:: INLINE void dallocator<Type>::
//deallocate(dallocator<Type>::pointer p, allocator<Type>::size_type) { //deallocate(dallocator<Type>::pointer p, allocator<Type>::size_type) {
deallocate(void *p, allocator<Type>::size_type) { deallocate(void *p, allocator<Type>::size_type) {
default_operator_delete(p); default_operator_delete(p);
} }
#endif // NDEBUG #endif // NDEBUG
#endif // GCC_STYLE_ALLOCATOR #endif // GCC_STYLE_ALLOCATOR

View File

@ -1,68 +1,68 @@
// Filename: dallocator.h // Filename: dallocator.h
// Created by: drose (05Jun01) // Created by: drose (05Jun01)
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// //
// PANDA 3D SOFTWARE // PANDA 3D SOFTWARE
// Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
// //
// All use of this software is subject to the terms of the Panda 3d // 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 // Software license. You should have received a copy of this license
// along with this source code; you will also find a current copy of // along with this source code; you will also find a current copy of
// the license at http://www.panda3d.org/license.txt . // the license at http://www.panda3d.org/license.txt .
// //
// To contact the maintainers of this program write to // To contact the maintainers of this program write to
// panda3d@yahoogroups.com . // panda3d@yahoogroups.com .
// //
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifndef DALLOCATOR_H #ifndef DALLOCATOR_H
#define DALLOCATOR_H #define DALLOCATOR_H
#include "dtoolbase.h" #include "dtoolbase.h"
#include <memory> #include <memory>
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Class : dallocator // Class : dallocator
// Description : This is similar to pallocator, but always uses the // Description : This is similar to pallocator, but always uses the
// default new and delete handlers defined in // default new and delete handlers defined in
// dtoolbase_cc.h; it never calls the hooks assigned by // dtoolbase_cc.h; it never calls the hooks assigned by
// redefining global_operator_new, etc. // redefining global_operator_new, etc.
// //
// This is needed in those rare cases when we need to // This is needed in those rare cases when we need to
// allocate memory for STL without going through the // allocate memory for STL without going through the
// callback hooks, for instance to implement STL tables // callback hooks, for instance to implement STL tables
// within the MemoryUsage class itself. // within the MemoryUsage class itself.
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#ifdef GCC_STYLE_ALLOCATOR #ifdef GCC_STYLE_ALLOCATOR
// Early versions of gcc used its own kind of allocator, somewhat // Early versions of gcc used its own kind of allocator, somewhat
// different from the STL standard. // different from the STL standard.
template<class Type> template<class Type>
class dallocator : public alloc { class dallocator : public alloc {
public: public:
#ifndef NDEBUG #ifndef NDEBUG
static void *allocate(size_t n); static void *allocate(size_t n);
static void deallocate(void *p, size_t n); static void deallocate(void *p, size_t n);
#endif // NDEBUG #endif // NDEBUG
}; };
#else // GCC_STYLE_ALLOCATOR #else // GCC_STYLE_ALLOCATOR
template<class Type> template<class Type>
class dallocator : public allocator<Type> { class dallocator : public allocator<Type> {
public: public:
#ifndef NDEBUG #ifndef NDEBUG
INLINE pointer allocate(size_type n, allocator<void>::const_pointer hint = 0); INLINE pointer allocate(size_type n, allocator<void>::const_pointer hint = 0);
// INLINE void deallocate(pointer p, size_type n); // INLINE void deallocate(pointer p, size_type n);
INLINE void deallocate(void *p, size_type n); INLINE void deallocate(void *p, size_type n);
#endif // NDEBUG #endif // NDEBUG
}; };
#endif // GCC_STYLE_ALLOCATOR #endif // GCC_STYLE_ALLOCATOR
#include "dallocator.T" #include "dallocator.T"
#endif #endif