diff options
author | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-09 03:00:03 +0000 |
---|---|---|
committer | coryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-07-09 03:00:03 +0000 |
commit | fefcfb9a402cdfc13aa0f095f1cb5765fdd25084 (patch) | |
tree | 38d23918b830fb88e5c683ea852e1df29f0f5551 | |
parent | caf101c59d5f4bf54a1b71807a6f0794e58d1b88 (diff) | |
download | ATCD-fefcfb9a402cdfc13aa0f095f1cb5765fdd25084.tar.gz |
ChangeLogTag:Thu Jul 8 21:57:17 1999 Carlos O'Ryan <coryan@cs.wustl.edu>
-rw-r--r-- | ChangeLog-99b | 11 | ||||
-rw-r--r-- | ace/Malloc_T.cpp | 15 | ||||
-rw-r--r-- | ace/Malloc_T.h | 2 |
3 files changed, 18 insertions, 10 deletions
diff --git a/ChangeLog-99b b/ChangeLog-99b index 3557abe0075..75caf00b7cd 100644 --- a/ChangeLog-99b +++ b/ChangeLog-99b @@ -1,3 +1,14 @@ +Thu Jul 8 21:57:17 1999 Carlos O'Ryan <coryan@cs.wustl.edu> + + * ace/Malloc_T.h: + * ace/Malloc_T.cpp: + Changed the Cached_Allocator class to use a char* as the memory + source. + It was allocated as char* and deallocated as a char*, but casted + to T* to use placement new; this was actually unneeded and + actually an error: the memory does not become a T* until + placement new is invoked on it. [BUGID:40] + Thu Jul 08 21:34:42 1999 David L. Levine <levine@cs.wustl.edu> * ace/config-lynxos.h: on PowerPC, set diff --git a/ace/Malloc_T.cpp b/ace/Malloc_T.cpp index 2d2fcc17ad8..946e026b256 100644 --- a/ace/Malloc_T.cpp +++ b/ace/Malloc_T.cpp @@ -22,17 +22,16 @@ ACE_Cached_Allocator<T, ACE_LOCK>::ACE_Cached_Allocator (size_t n_chunks) : pool_ (0), free_list_ (ACE_PURE_FREE_LIST) { - char *tmp = 0; - - ACE_NEW (tmp, + ACE_NEW (this->pool_, char[n_chunks * sizeof (T)]); - this->pool_ = ACE_reinterpret_cast (T *, - tmp); for (size_t c = 0; c < n_chunks; c++) - this->free_list_.add (new (&this->pool_ [c]) ACE_Cached_Mem_Pool_Node<T>); + { + void* placement = this->pool_ + c * sizeof(T); + this->free_list_.add (new (placement) ACE_Cached_Mem_Pool_Node<T>); + } // Put into free list using placement contructor, no real memory // allocation in the above <new>. } @@ -40,9 +39,7 @@ ACE_Cached_Allocator<T, ACE_LOCK>::ACE_Cached_Allocator (size_t n_chunks) template <class T, class ACE_LOCK> ACE_Cached_Allocator<T, ACE_LOCK>::~ACE_Cached_Allocator (void) { - char *tmp = ACE_reinterpret_cast (char *, - this->pool_); - delete [] tmp; + delete [] this->pool_; } ACE_ALLOC_HOOK_DEFINE (ACE_Malloc) diff --git a/ace/Malloc_T.h b/ace/Malloc_T.h index b41afe45986..fcfbb414ce1 100644 --- a/ace/Malloc_T.h +++ b/ace/Malloc_T.h @@ -85,7 +85,7 @@ public: // return a chunk of memory back to free store. private: - T *pool_; + char *pool_; // remember how we allocate the memory in the first place so // we can clear things up later. |