diff options
author | Steve Huston <shuston@riverace.com> | 2020-05-30 17:03:54 +0000 |
---|---|---|
committer | Steve Huston <shuston@riverace.com> | 2020-05-30 17:03:54 +0000 |
commit | 6d11e3bddbaf2dd3591aa2a2bf4bb694ff00fe06 (patch) | |
tree | eceb63d13fd7aa6286726872341d597c3e4e4b3d | |
parent | bd3ff908aa97bd8ae452666078c2c3bb870661d0 (diff) | |
parent | a59ce5fc7238ed77b662d4d5b268c3bfbdb034ca (diff) | |
download | ATCD-6d11e3bddbaf2dd3591aa2a2bf4bb694ff00fe06.tar.gz |
Merge branch 'det' into Riverace-6.2
-rw-r--r-- | ACE/ace/Malloc_T.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/ACE/ace/Malloc_T.cpp b/ACE/ace/Malloc_T.cpp index d98b5c95672..cedde89d686 100644 --- a/ACE/ace/Malloc_T.cpp +++ b/ACE/ace/Malloc_T.cpp @@ -64,9 +64,8 @@ ACE_Cached_Allocator<T, ACE_LOCK>::malloc (size_t nbytes) if (nbytes > sizeof (T)) return 0; - // addr() call is really not absolutely necessary because of the way - // ACE_Cached_Mem_Pool_Node's internal structure arranged. - return this->free_list_.remove ()->addr (); + ACE_Cached_Mem_Pool_Node<T> *allocated = this->free_list_.remove (); + return allocated == 0 ? 0 : allocated->addr(); } template <class T, class ACE_LOCK> void * @@ -77,9 +76,8 @@ ACE_Cached_Allocator<T, ACE_LOCK>::calloc (size_t nbytes, if (nbytes > sizeof (T)) return 0; - // addr() call is really not absolutely necessary because of the way - // ACE_Cached_Mem_Pool_Node's internal structure arranged. - void *ptr = this->free_list_.remove ()->addr (); + ACE_Cached_Mem_Pool_Node<T> *allocated = this->free_list_.remove (); + void *ptr = allocated == 0 ? 0 : allocated->addr(); if (ptr != 0) ACE_OS::memset (ptr, initial_value, sizeof (T)); return ptr; @@ -138,9 +136,8 @@ ACE_Dynamic_Cached_Allocator<ACE_LOCK>::malloc (size_t nbytes) if (nbytes > chunk_size_) return 0; - // addr() call is really not absolutely necessary because of the way - // ACE_Cached_Mem_Pool_Node's internal structure arranged. - return this->free_list_.remove ()->addr (); + ACE_Cached_Mem_Pool_Node<char> *allocated = this->free_list_.remove (); + return allocated == 0 ? 0 : allocated->addr(); } template <class ACE_LOCK> void * @@ -151,9 +148,8 @@ ACE_Dynamic_Cached_Allocator<ACE_LOCK>::calloc (size_t nbytes, if (nbytes > chunk_size_) return 0; - // addr() call is really not absolutely necessary because of the way - // ACE_Cached_Mem_Pool_Node's internal structure arranged. - void *ptr = this->free_list_.remove ()->addr (); + ACE_Cached_Mem_Pool_Node<char> *allocated = this->free_list_.remove (); + void *ptr = allocated == 0 ? 0 : allocated->addr(); if (ptr != 0) ACE_OS::memset (ptr, initial_value, chunk_size_); return ptr; |