Malloc.cpp

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

Generated on Thu Nov 9 09:41:54 2006 for ACE by doxygen 1.3.6