pallocator.T 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Filename: pallocator.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 *pallocator<Type>::
  21. allocate(size_t n) {
  22. return (Type *)(*global_operator_new)(n);
  23. }
  24. template<class Type>
  25. INLINE void pallocator<Type>::
  26. deallocate(void *p, size_t) {
  27. (*global_operator_delete)(p);
  28. }
  29. #elif defined(GNU_STYLE_ALLOCATOR)
  30. template<class Type>
  31. INLINE pallocator<Type>::
  32. pallocator() {
  33. }
  34. template<class Type>
  35. template<class _Tp1>
  36. INLINE pallocator<Type>::
  37. pallocator(const pallocator<_Tp1> &) {
  38. }
  39. template<class Type>
  40. INLINE Type *pallocator<Type>::
  41. allocate(size_t n) {
  42. return (Type *)(*global_operator_new)(n * sizeof(Type));
  43. }
  44. template<class Type>
  45. INLINE void pallocator<Type>::
  46. deallocate(void *p, size_t) {
  47. (*global_operator_delete)(p);
  48. }
  49. #elif VC6_STYLE_ALLOCATOR
  50. template<class Type>
  51. INLINE pallocator<Type>::pointer pallocator<Type>::
  52. allocate(pallocator<Type>::size_type n, allocator<void>::const_pointer) {
  53. return (pallocator<Type>::pointer)(*global_operator_new)(n * sizeof(Type));
  54. }
  55. template<class Type>
  56. INLINE void pallocator<Type>::
  57. //deallocate(pallocator<Type>::pointer p, allocator<Type>::size_type) {
  58. deallocate(void *p, allocator<Type>::size_type) {
  59. (*global_operator_delete)(p);
  60. }
  61. #elif MODERN_STYLE_ALLOCATOR
  62. template<class Type>
  63. INLINE pallocator<Type>::
  64. pallocator() throw() {
  65. }
  66. template<class Type>
  67. INLINE TYPENAME pallocator<Type>::pointer pallocator<Type>::
  68. allocate(TYPENAME pallocator<Type>::size_type n, TYPENAME allocator<void>::const_pointer) {
  69. return (TYPENAME pallocator<Type>::pointer)(*global_operator_new)(n * sizeof(Type));
  70. }
  71. template<class Type>
  72. INLINE void pallocator<Type>::
  73. //deallocate(pallocator<Type>::pointer p, allocator<Type>::size_type) {
  74. deallocate(void *p, allocator<Type>::size_type) {
  75. (*global_operator_delete)(p);
  76. }
  77. #endif // *_STYLE_ALLOCATOR