Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / ace / Malloc.cpp
blobde9f79aad1d3c59d90880edd76283dab6b7a49e9
1 #include "ace/Malloc.h"
3 #if !defined (__ACE_INLINE__)
4 #include "ace/Malloc.inl"
5 #endif /* __ACE_INLINE__ */
7 #include "ace/Object_Manager.h"
8 #include "ace/Malloc_Base.h"
9 #include "ace/OS_NS_string.h"
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 // Process-wide ACE_Allocator.
14 ACE_Allocator *ACE_Allocator::allocator_ = 0;
16 void
17 ACE_Control_Block::ACE_Malloc_Header::dump () const
19 #if defined (ACE_HAS_DUMP)
20 ACE_TRACE ("ACE_Control_Block::ACE_Malloc_Header::dump");
22 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
23 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_block = %@"), (ACE_Malloc_Header *) this->next_block_));
24 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nsize = %d\n"), this->size_));
25 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
26 #endif /* ACE_HAS_DUMP */
29 void
30 ACE_Control_Block::print_alignment_info ()
32 #if defined (ACE_HAS_DUMP)
33 ACE_TRACE ("ACE_Control_Block::print_alignment_info");
34 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("Start ---> ACE_Control_Block::print_alignment_info:\n")));
35 ACELIB_DEBUG ((LM_DEBUG,
36 ACE_TEXT ("Sizeof ptr: %d\n")
37 ACE_TEXT ("Sizeof size_t: %d\n")
38 ACE_TEXT ("Sizeof long: %d\n")
39 ACE_TEXT ("Sizeof double: %d\n")
40 ACE_TEXT ("Sizeof ACE_MALLOC_ALIGN: %d\n")
41 ACE_TEXT ("Sizeof ACE_MALLOC_PADDING: %d\n")
42 ACE_TEXT ("Sizeof ACE_MALLOC_HEADER_SIZE: %d\n")
43 ACE_TEXT ("Sizeof ACE_MALLOC_PADDING_SIZE: %d\n")
44 ACE_TEXT ("Sizeof ACE_CONTROL_BLOCK_SIZE: %d\n")
45 ACE_TEXT ("Sizeof ACE_CONTROL_BLOCK_ALIGN_BYTES: %d\n")
46 ACE_TEXT ("Sizeof (MALLOC_HEADER): %d\n")
47 ACE_TEXT ("Sizeof (CONTROL_BLOCK): %d\n"),
48 sizeof (char *),
49 sizeof (size_t),
50 sizeof (long),
51 sizeof (double),
52 ACE_MALLOC_ALIGN,
53 ACE_MALLOC_PADDING,
54 ACE_MALLOC_HEADER_SIZE,
55 ACE_MALLOC_PADDING_SIZE,
56 ACE_CONTROL_BLOCK_SIZE,
57 ACE_CONTROL_BLOCK_ALIGN_BYTES,
58 sizeof (ACE_Malloc_Header),
59 sizeof (ACE_Control_Block)
60 ));
61 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("End <--- ACE_Control_Block::print_alignment_info:\n")));
62 #endif /* ACE_HAS_DUMP */
65 void
66 ACE_Control_Block::dump () const
68 #if defined (ACE_HAS_DUMP)
69 ACE_TRACE ("ACE_Control_Block::dump");
71 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
72 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("Name Node:\n")));
73 for (ACE_Name_Node *nextn = this->name_head_;
74 nextn != 0;
75 nextn = nextn->next_)
76 nextn->dump ();
78 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("freep_ = %@"), (ACE_Malloc_Header *) this->freep_));
79 this->base_.dump ();
81 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nMalloc Header:\n")));
82 for (ACE_Malloc_Header *nexth = ((ACE_Malloc_Header *)this->freep_)->next_block_;
83 nexth != 0 && nexth != &this->base_;
84 nexth = nexth->next_block_)
85 nexth->dump ();
87 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\n")));
88 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
89 #endif /* ACE_HAS_DUMP */
92 ACE_Control_Block::ACE_Name_Node::ACE_Name_Node ()
93 : name_ (0),
94 pointer_ (0),
95 next_ (0),
96 prev_ (0)
98 ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::ACE_Name_Node");
101 ACE_Control_Block::ACE_Name_Node::ACE_Name_Node (const char *name,
102 char *name_ptr,
103 char *pointer,
104 ACE_Name_Node *next)
105 : name_ (name_ptr),
106 pointer_ (pointer),
107 next_ (next),
108 prev_ (0)
110 ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::ACE_Name_Node");
111 char *n = this->name_;
112 ACE_OS::strcpy (n, name);
113 if (next != 0)
114 next->prev_ = this;
117 const char *
118 ACE_Control_Block::ACE_Name_Node::name () const
120 return this->name_;
123 ACE_Control_Block::ACE_Malloc_Header::ACE_Malloc_Header ()
124 : next_block_ (0),
125 size_ (0)
129 void
130 ACE_Control_Block::ACE_Name_Node::dump () const
132 #if defined (ACE_HAS_DUMP)
133 ACE_TRACE ("ACE_Control_Block::ACE_Name_Node::dump");
135 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
136 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("pointer = %@"), (const char *) this->pointer_));
137 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT ("\nnext_ = %@"), (ACE_Name_Node *) this->next_));
138 ACELIB_DEBUG ((LM_DEBUG,
139 ACE_TEXT ("\nname_ = (%@, %C)\n"),
140 (const char *) this->name_,
141 (const char *) this->name_));
142 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
143 #endif /* ACE_HAS_DUMP */
147 #if defined (ACE_HAS_MALLOC_STATS)
148 ACE_Malloc_Stats::ACE_Malloc_Stats ()
149 : nchunks_ (0),
150 nblocks_ (0),
151 ninuse_ (0)
153 ACE_TRACE ("ACE_Malloc_Stats::ACE_Malloc_Stats");
156 void
157 ACE_Malloc_Stats::dump () const
159 #if defined (ACE_HAS_DUMP)
160 ACE_TRACE ("ACE_Malloc_Stats::dump");
162 ACELIB_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
163 int const nblocks = this->nblocks_.value ();
164 int const ninuse = this->ninuse_.value ();
165 int const nchunks = this->nchunks_.value ();
167 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT("nblocks = %d"), nblocks));
168 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT("\nninuse = %d"), ninuse));
169 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT("\nnchunks = %d"), nchunks));
170 ACELIB_DEBUG ((LM_DEBUG, ACE_TEXT("\n")));
171 ACELIB_DEBUG ((LM_DEBUG, ACE_END_DUMP));
172 #endif /* ACE_HAS_DUMP */
175 #endif /*ACE_HAS_MALLOC_STATS*/
177 ACE_END_VERSIONED_NAMESPACE_DECL