dallocator.T 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. // Filename: dallocator.T
  2. // Created by: drose (05Jun01)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://www.panda3d.org/license.txt .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #if defined(OLD_STYLE_ALLOCATOR)
  19. template<class Type>
  20. INLINE Type *dallocator<Type>::
  21. allocate(size_t n) {
  22. return (Type *)default_operator_new(n);
  23. }
  24. template<class Type>
  25. INLINE void dallocator<Type>::
  26. deallocate(void *p, size_t) {
  27. default_operator_delete(p);
  28. }
  29. #elif defined(GNU_STYLE_ALLOCATOR)
  30. template<class Type>
  31. INLINE dallocator<Type>::
  32. dallocator() {
  33. }
  34. template<class Type>
  35. template<class _Tp1>
  36. INLINE dallocator<Type>::
  37. dallocator(const dallocator<_Tp1> &) {
  38. }
  39. template<class Type>
  40. INLINE Type *dallocator<Type>::
  41. allocate(size_t n) {
  42. return (Type *)default_operator_new(n * sizeof(Type));
  43. }
  44. template<class Type>
  45. INLINE void dallocator<Type>::
  46. deallocate(void *p, size_t) {
  47. default_operator_delete(p);
  48. }
  49. #elif MODERN_STYLE_ALLOCATOR
  50. template<class Type>
  51. INLINE dallocator<Type>::
  52. dallocator() throw() {
  53. }
  54. template<class Type>
  55. INLINE TYPENAME dallocator<Type>::pointer dallocator<Type>::
  56. allocate(TYPENAME dallocator<Type>::size_type n, allocator<void>::const_pointer) {
  57. return (TYPENAME dallocator<Type>::pointer)(*global_operator_new)(n * sizeof(Type));
  58. }
  59. template<class Type>
  60. INLINE void dallocator<Type>::
  61. //deallocate(dallocator<Type>::pointer p, allocator<Type>::size_type) {
  62. deallocate(void *p, allocator<Type>::size_type) {
  63. (*global_operator_delete)(p);
  64. }
  65. #endif // *_STYLE_ALLOCATOR