Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Malloc.cpp

Go to the documentation of this file.
00001 #include "ace_pch.h"
00002 // $Id: Malloc.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:21 chad Exp $
00003 
00004 #if !defined (ACE_MALLOC_CPP)
00005 #define ACE_MALLOC_CPP
00006 
00007 #include "ace/Malloc.h"
00008 #include "ace/Object_Manager.h"
00009 
00010 #if !defined (__ACE_INLINE__)
00011 #include "ace/Malloc.i"
00012 #endif /* __ACE_INLINE__ */
00013 
00014 #include "ace/Synch_T.h"
00015 
00016 ACE_RCSID(ace, Malloc, "$Id: Malloc.cpp,v 1.1.1.4.2.1 2003/03/13 19:44:21 chad Exp $")
00017 
00018 // Process-wide ACE_Allocator.
00019 ACE_Allocator *ACE_Allocator::allocator_ = 0;
00020 
00021 // Controls whether the Allocator is deleted when we shut down (we can
00022 // only delete it safely if we created it!)  This is no longer used;
00023 // see ACE_Allocator::instance (void).
00024 int ACE_Allocator::delete_allocator_ = 0;
00025 
00026 void
00027 ACE_Control_Block::ACE_Malloc_Header::dump (void) const
00028 {
00029   ACE_TRACE ("ACE_Control_Block::ACE_Malloc_Header::dump");
00030 
00031   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00032   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nnext_block = %@"), (ACE_Malloc_Header *) this->next_block_));
00033   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nsize = %d\n"), this->size_));
00034   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00035 }
00036 
00037 void
00038 ACE_Control_Block::print_alignment_info (void)
00039 {
00040   ACE_TRACE ("ACE_Control_Block::print_alignment_info");
00041   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("Start ---> ACE_Control_Block::print_alignment_info:\n")));
00042   ACE_DEBUG ((LM_DEBUG,
00043               ACE_LIB_TEXT ("Sizeof ptr: %d\n")
00044               ACE_LIB_TEXT ("Sizeof size_t: %d\n")
00045               ACE_LIB_TEXT ("Sizeof long: %d\n")
00046               ACE_LIB_TEXT ("Sizeof double: %d\n")
00047               ACE_LIB_TEXT ("Sizeof ACE_MALLOC_ALIGN: %d\n")
00048               ACE_LIB_TEXT ("Sizeof ACE_MALLOC_PADDING: %d\n")
00049               ACE_LIB_TEXT ("Sizeof ACE_MALLOC_HEADER_SIZE: %d\n")
00050               ACE_LIB_TEXT ("Sizeof ACE_MALLOC_PADDING_SIZE: %d\n")
00051               ACE_LIB_TEXT ("Sizeof ACE_CONTROL_BLOCK_SIZE: %d\n")
00052               ACE_LIB_TEXT ("Sizeof ACE_CONTROL_BLOCK_ALIGN_LONGS: %d\n")
00053               ACE_LIB_TEXT ("Sizeof (MALLOC_HEADER): %d\n")
00054               ACE_LIB_TEXT ("Sizeof (CONTROL_BLOCK): %d\n"),
00055               sizeof (char *),
00056               sizeof (size_t),
00057               sizeof (long),
00058               sizeof (double),
00059               ACE_MALLOC_ALIGN,
00060               ACE_MALLOC_PADDING,
00061               ACE_MALLOC_HEADER_SIZE,
00062               ACE_MALLOC_PADDING_SIZE,
00063               ACE_CONTROL_BLOCK_SIZE,
00064               ACE_CONTROL_BLOCK_ALIGN_LONGS,
00065               sizeof (ACE_Malloc_Header),
00066               sizeof (ACE_Control_Block)
00067               ));
00068   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("End <--- ACE_Control_Block::print_alignment_info:\n")));
00069 }
00070 
00071 void
00072 ACE_Control_Block::dump (void) const
00073 {
00074   ACE_TRACE ("ACE_Control_Block::dump");
00075 
00076   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00077   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("Name Node:\n")));
00078   for (ACE_Name_Node *nextn = this->name_head_;
00079        nextn != 0;
00080        nextn = nextn->next_)
00081     nextn->dump ();
00082 
00083   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("freep_ = %@"), (ACE_Malloc_Header *) this->freep_));
00084   this->base_.dump ();
00085 
00086   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nMalloc Header:\n")));
00087   for (ACE_Malloc_Header *nexth = ((ACE_Malloc_Header *)this->freep_)->next_block_;
00088        nexth != 0 && nexth != &this->base_;
00089        nexth = nexth->next_block_)
00090     nexth->dump ();
00091 
00092   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
00093   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00094 }
00095 
00096 ACE_Control_Block::ACE_Name_Node::ACE_Name_Node (void)
00097 {
00098   ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::ACE_Name_Node");
00099 }
00100 
00101 ACE_Control_Block::ACE_Name_Node::ACE_Name_Node (const char *name,
00102                                                  char *name_ptr,
00103                                                  char *pointer,
00104                                                  ACE_Name_Node *next)
00105   : name_ (name_ptr),
00106     pointer_ (pointer),
00107     next_ (next),
00108     prev_ (0)
00109 {
00110   ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::ACE_Name_Node");
00111   char *n = this->name_;
00112   ACE_OS::strcpy (n, name);
00113   if (next != 0)
00114     next->prev_ = this;
00115 }
00116 
00117 ACE_Control_Block::ACE_Name_Node::ACE_Name_Node (const ACE_Name_Node &)
00118 {
00119   ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::ACE_Name_Node");
00120 #if !defined (ACE_PSOS)
00121   ACE_ASSERT (!"not implemented!");
00122 #endif /* ! ACE_PSOS */
00123 }
00124 
00125 const char *
00126 ACE_Control_Block::ACE_Name_Node::name (void) const
00127 {
00128   const char *c = this->name_;
00129   return c;
00130 }
00131 
00132 void
00133 ACE_Control_Block::ACE_Name_Node::name (const char *)
00134 {
00135 #if !defined (ACE_PSOS)
00136   ACE_ASSERT (0 == "not implemented!");
00137 #endif /* ! ACE_PSOS */
00138 }
00139 
00140 ACE_Control_Block::ACE_Malloc_Header::ACE_Malloc_Header (void)
00141   : next_block_ (0),
00142     size_ (0)
00143 {
00144 }
00145 
00146 void
00147 ACE_Control_Block::ACE_Name_Node::dump (void) const
00148 {
00149   ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::dump");
00150 
00151   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00152   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("pointer = %@"), (const char *) this->pointer_));
00153   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nnext_ = %@"), (ACE_Name_Node *) this->next_));
00154   ACE_DEBUG ((LM_DEBUG,
00155               ACE_LIB_TEXT ("\nname_ = (%@, %s)"),
00156               (const char *) this->name_,
00157               (const char *) this->name_));
00158   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
00159   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00160 }
00161 
00162 
00163 #if defined (ACE_HAS_MALLOC_STATS)
00164 ACE_Malloc_Stats::ACE_Malloc_Stats (void)
00165   : nchunks_ (0),
00166     nblocks_ (0),
00167     ninuse_ (0)
00168 {
00169   ACE_TRACE ("ACE_Malloc_Stats::ACE_Malloc_Stats");
00170 }
00171 
00172 void
00173 ACE_Malloc_Stats::dump (void) const
00174 {
00175   ACE_TRACE ("ACE_Malloc_Stats::dump");
00176 
00177   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00178   int nblocks = this->nblocks_.value ();
00179   int ninuse  = this->ninuse_.value ();
00180   int nchunks = this->nchunks_.value ();
00181 
00182   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT("nblocks = %d"), nblocks));
00183   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT("\nninuse = %d"), ninuse));
00184   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT("\nnchunks = %d"), nchunks));
00185   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT("\n")));
00186   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00187 }
00188 
00189 #if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
00190 template class ACE_Atomic_Op<ACE_PROCESS_MUTEX, int>;
00191 template class ACE_Atomic_Op_Ex<ACE_PROCESS_MUTEX, int>;
00192 #elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
00193 #pragma instantiate ACE_Atomic_Op<ACE_PROCESS_MUTEX, int>
00194 #pragma instantiate ACE_Atomic_Op_Ex<ACE_PROCESS_MUTEX, int>
00195 #endif /* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */
00196 #endif /*ACE_HAS_MALLOC_STATS*/
00197 #endif /* ACE_MALLOC_CPP */

Generated on Mon Jun 16 11:20:04 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002