00001 #include "ace_pch.h"
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012 #if !defined (ACE_MALLOC_ALLOCATOR_CPP)
00013 #define ACE_MALLOC_ALLOCATOR_CPP
00014
00015 #include "ace/Malloc_Allocator.h"
00016 #include "ace/Object_Manager.h"
00017
00018 #if !defined (__ACE_INLINE__)
00019 #include "ace/Malloc_Allocator.i"
00020 #endif
00021
00022 #include "ace/Synch_T.h"
00023
00024 ACE_RCSID (ace, Malloc_Allocator, "$Id: Malloc_Allocator.cpp,v 1.1.1.2.2.1 2003/03/13 19:44:21 chad Exp $")
00025
00026 ACE_Allocator *
00027 ACE_Allocator::instance (void)
00028 {
00029
00030
00031 if (ACE_Allocator::allocator_ == 0)
00032 {
00033
00034 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00035 *ACE_Static_Object_Lock::instance (), 0));
00036
00037 if (ACE_Allocator::allocator_ == 0)
00038 {
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053 static void *allocator_instance = 0;
00054
00055
00056
00057
00058 # if !defined (ACE_NDEBUG)
00059 int assertion = (sizeof allocator_instance ==
00060 sizeof (ACE_New_Allocator));
00061 ACE_ASSERT (assertion);
00062 # endif
00063
00064
00065
00066 ACE_Allocator::allocator_ =
00067 new (&allocator_instance) ACE_New_Allocator;
00068 }
00069 }
00070
00071 return ACE_Allocator::allocator_;
00072 }
00073
00074 ACE_Allocator *
00075 ACE_Allocator::instance (ACE_Allocator *r)
00076 {
00077 ACE_TRACE ("ACE_Allocator::instance");
00078 ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00079 *ACE_Static_Object_Lock::instance (), 0));
00080 ACE_Allocator *t = ACE_Allocator::allocator_;
00081
00082
00083 ACE_Allocator::delete_allocator_ = 0;
00084
00085 ACE_Allocator::allocator_ = r;
00086 return t;
00087 }
00088
00089 void
00090 ACE_Allocator::close_singleton (void)
00091 {
00092 ACE_TRACE ("ACE_Allocator::close_singleton");
00093
00094 ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00095 *ACE_Static_Object_Lock::instance ()));
00096
00097 if (ACE_Allocator::delete_allocator_)
00098 {
00099
00100
00101 delete ACE_Allocator::allocator_;
00102 ACE_Allocator::allocator_ = 0;
00103 ACE_Allocator::delete_allocator_ = 0;
00104 }
00105 }
00106
00107 ACE_Allocator::~ACE_Allocator (void)
00108 {
00109 ACE_TRACE ("ACE_Allocator::~ACE_Allocator");
00110 }
00111
00112 ACE_Allocator::ACE_Allocator (void)
00113 {
00114 ACE_TRACE ("ACE_Allocator::ACE_Allocator");
00115 }
00116
00117 void
00118 ACE_Static_Allocator_Base::dump (void) const
00119 {
00120 ACE_TRACE ("ACE_Static_Allocator_Base::dump");
00121
00122 ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00123 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\noffset_ = %d"), this->offset_));
00124 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nsize_ = %d\n"), this->size_));
00125 ACE_HEX_DUMP ((LM_DEBUG, this->buffer_, this->size_));
00126 ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
00127
00128 ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00129 }
00130
00131
00132
00133 #endif