Fixed typos
[ACE_TAO.git] / ACE / ace / Local_Memory_Pool.cpp
blob0332f6f36e0d30f362617f159b15fe255ae32a31
1 // Local_Memory_Pool.cpp
2 #include "ace/Local_Memory_Pool.h"
3 #include "ace/Auto_Ptr.h"
4 #include "ace/OS_Memory.h"
5 #include "ace/Log_Category.h"
9 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
11 ACE_ALLOC_HOOK_DEFINE(ACE_Local_Memory_Pool)
13 void
14 ACE_Local_Memory_Pool::dump (void) const
16 #if defined (ACE_HAS_DUMP)
17 ACE_TRACE ("ACE_Local_Memory_Pool::dump");
18 #endif /* ACE_HAS_DUMP */
21 ACE_Local_Memory_Pool::ACE_Local_Memory_Pool (const ACE_TCHAR *,
22 const OPTIONS *)
24 ACE_TRACE ("ACE_Local_Memory_Pool::ACE_Local_Memory_Pool");
27 ACE_Local_Memory_Pool::~ACE_Local_Memory_Pool (void)
29 // Free up all memory allocated by this pool.
30 this->release ();
33 // Ask system for initial chunk of local memory.
34 void *
35 ACE_Local_Memory_Pool::init_acquire (size_t nbytes,
36 size_t &rounded_bytes,
37 int &first_time)
39 ACE_TRACE ("ACE_Local_Memory_Pool::init_acquire");
40 // Note that we assume that when ACE_Local_Memory_Pool is used,
41 // ACE_Malloc's constructor will only get called once. If this
42 // assumption doesn't hold, we are in deep trouble!
44 first_time = 1;
45 return this->acquire (nbytes, rounded_bytes);
48 void *
49 ACE_Local_Memory_Pool::acquire (size_t nbytes,
50 size_t &rounded_bytes)
52 ACE_TRACE ("ACE_Local_Memory_Pool::acquire");
53 rounded_bytes = this->round_up (nbytes);
55 char *temp = 0;
56 #if defined (ACE_HAS_ALLOC_HOOKS)
57 ACE_ALLOCATOR_RETURN (temp,
58 static_cast<char*>(ACE_Allocator::instance()->malloc(sizeof(char) * rounded_bytes)),
59 0);
60 #else
61 ACE_NEW_RETURN (temp,
62 char[rounded_bytes],
63 0);
64 #endif /* ACE_HAS_ALLOC_HOOKS */
66 ACE_Auto_Basic_Array_Ptr<char> cp (temp);
68 if (this->allocated_chunks_.insert (cp.get ()) != 0)
69 ACELIB_ERROR_RETURN ((LM_ERROR,
70 ACE_TEXT ("(%P|%t) insertion into set failed\n")),
71 0);
73 return cp.release ();
76 int
77 ACE_Local_Memory_Pool::release (int)
79 ACE_TRACE ("ACE_Local_Memory_Pool::release");
81 // Zap the memory we allocated.
82 for (ACE_Unbounded_Set<char *>::iterator i = this->allocated_chunks_.begin ();
83 i != this->allocated_chunks_.end ();
84 ++i)
85 #if defined (ACE_HAS_ALLOC_HOOKS)
86 ACE_Allocator::instance()->free(*i);
87 #else
88 delete [] *i;
89 #endif /* ACE_HAS_ALLOC_HOOKS */
91 this->allocated_chunks_.reset ();
92 return 0;
95 int
96 ACE_Local_Memory_Pool::sync (ssize_t, int)
98 ACE_TRACE ("ACE_Local_Memory_Pool::sync");
99 return 0;
103 ACE_Local_Memory_Pool::sync (void *, size_t, int)
105 ACE_TRACE ("ACE_Local_Memory_Pool::sync");
106 return 0;
110 ACE_Local_Memory_Pool::protect (ssize_t, int)
112 ACE_TRACE ("ACE_Local_Memory_Pool::protect");
113 return 0;
117 ACE_Local_Memory_Pool::protect (void *, size_t, int)
119 ACE_TRACE ("ACE_Local_Memory_Pool::protect");
120 return 0;
123 #if defined (ACE_WIN32)
125 ACE_Local_Memory_Pool::seh_selector (void *)
127 return 0;
128 // Continue propagate the structural exception up.
130 #endif /* ACE_WIN32 */
133 ACE_Local_Memory_Pool::remap (void *)
135 return 0;
136 // Not much can be done.
139 void *
140 ACE_Local_Memory_Pool::base_addr (void) const
142 return 0;
145 // Let the underlying new operator figure out the alignment...
146 size_t
147 ACE_Local_Memory_Pool::round_up (size_t nbytes)
149 ACE_TRACE ("ACE_Local_Memory_Pool::round_up");
150 return ACE::round_to_pagesize (nbytes);
153 ACE_END_VERSIONED_NAMESPACE_DECL