diff options
author | Adam Mitz <mitza@objectcomputing.com> | 2021-11-05 19:02:40 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-05 19:02:40 -0500 |
commit | 4ea4debc61a8e7cd52b483925072f833f6203a95 (patch) | |
tree | 55d956fb1d7f57ba1e3c0ec5235649a637027f33 | |
parent | 15e4737ddce6b0a73451e5f9856f7e5641b6173b (diff) | |
parent | 16330a8f2ece9ed2a36fe5af9c7d69efb195d44c (diff) | |
download | ATCD-4ea4debc61a8e7cd52b483925072f833f6203a95.tar.gz |
Merge pull request #1716 from mitza-oci/basedptr
Fixed ACE_Based_Pointer issues from #1709
-rw-r--r-- | ACE/ace/Based_Pointer_T.cpp | 22 | ||||
-rw-r--r-- | ACE/ace/Based_Pointer_T.h | 49 | ||||
-rw-r--r-- | ACE/ace/Based_Pointer_T.inl | 50 | ||||
-rw-r--r-- | ACE/ace/Malloc.h | 2 | ||||
-rw-r--r-- | ACE/ace/Malloc_T.cpp | 28 |
5 files changed, 58 insertions, 93 deletions
diff --git a/ACE/ace/Based_Pointer_T.cpp b/ACE/ace/Based_Pointer_T.cpp index e3504108156..9a1b64bd756 100644 --- a/ACE/ace/Based_Pointer_T.cpp +++ b/ACE/ace/Based_Pointer_T.cpp @@ -16,7 +16,7 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_ALLOC_HOOK_DEFINE_Tc(ACE_Based_Pointer_Basic) template <class CONCRETE> -ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (void) +ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer () { ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer"); } @@ -44,14 +44,14 @@ ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (CONCRETE *initial) } template <class CONCRETE> -ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (const void* base_addr, int) +ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (const void *base_addr, int) : ACE_Based_Pointer_Basic<CONCRETE> (base_addr, 0) { ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic"); } template <class CONCRETE> -ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic (void) +ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic () : target_ (0), base_offset_ (0) { @@ -100,22 +100,6 @@ ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic (CONCRETE *rhs) } } -template <class CONCRETE> -ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic<CONCRETE> &) -{ - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::ACE_Based_Pointer_Basic"); - - ACE_ASSERT (0); // not implemented. -} - -template <class CONCRETE> -ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer (const ACE_Based_Pointer<CONCRETE> &rhs) - : ACE_Based_Pointer_Basic<CONCRETE> (rhs) -{ - ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::ACE_Based_Pointer"); - ACE_ASSERT (0); // not implemented. -} - ACE_END_VERSIONED_NAMESPACE_DECL #endif /* ACE_BASED_POINTER_T_CPP */ diff --git a/ACE/ace/Based_Pointer_T.h b/ACE/ace/Based_Pointer_T.h index 33085713804..902e90f2a36 100644 --- a/ACE/ace/Based_Pointer_T.h +++ b/ACE/ace/Based_Pointer_T.h @@ -59,7 +59,7 @@ public: * based-pointer uses its address as an offset to it's base * address 0. */ - ACE_Based_Pointer_Basic (void); + ACE_Based_Pointer_Basic (); /** * Initialize this object using the @a initial pointer. This @@ -84,48 +84,37 @@ public: */ ACE_Based_Pointer_Basic (CONCRETE *initial); - /// Copy constructor. - ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic<CONCRETE> &); + ACE_Based_Pointer_Basic (const ACE_Based_Pointer_Basic &) = delete; + ACE_Based_Pointer_Basic (ACE_Based_Pointer_Basic &&) = delete; /// Constructor for know base address. @a o is only used to /// resolve overload ambiguity. ACE_Based_Pointer_Basic (const void *base_addr, int o); - /// Pseudo-assignment operator. - void operator = (CONCRETE *from); + void operator= (CONCRETE *from); - /// Pseudo-assignment operator. - void operator = (const ACE_Based_Pointer_Basic<CONCRETE> &); + void operator= (const ACE_Based_Pointer_Basic &); - /// Dereference operator. CONCRETE operator * () const; - /// Less than operator. - bool operator < (const ACE_Based_Pointer_Basic<CONCRETE> &) const; + bool operator< (const ACE_Based_Pointer_Basic &) const; - /// Less than or equal operator. - bool operator <= (const ACE_Based_Pointer_Basic<CONCRETE> &) const; + bool operator<= (const ACE_Based_Pointer_Basic &) const; - /// Greater than operator. - bool operator > (const ACE_Based_Pointer_Basic<CONCRETE> &) const; + bool operator> (const ACE_Based_Pointer_Basic &) const; - /// Greater than or equal operator. - bool operator >= (const ACE_Based_Pointer_Basic<CONCRETE> &) const; + bool operator>= (const ACE_Based_Pointer_Basic &) const; - /// Equality operator. - bool operator == (const ACE_Based_Pointer_Basic<CONCRETE> &) const; + bool operator== (const ACE_Based_Pointer_Basic &) const; - /// Inequality operator. - bool operator != (const ACE_Based_Pointer_Basic<CONCRETE> &) const; + bool operator!= (const ACE_Based_Pointer_Basic &) const; - /// Subscript operator. - CONCRETE operator [](int index) const; + CONCRETE operator[] (int index) const; - /// Increment operator. void operator+= (int index); /// Returns the underlying memory address of the smart pointer. - operator CONCRETE *() const; + operator CONCRETE * () const; /// Returns the underlying memory address of the smart pointer. CONCRETE *addr () const; @@ -159,7 +148,7 @@ class ACE_Based_Pointer : public ACE_Based_Pointer_Basic<CONCRETE> public: /// Constructor. See constructor for ACE_Based_Pointer_Basic for /// details. - ACE_Based_Pointer (void); + ACE_Based_Pointer (); /// Initialize this object using the <initial> pointer. See /// constructor for ACE_Based_Pointer_Basic for details. @@ -170,17 +159,15 @@ public: /// otherwise ignored. ACE_Based_Pointer (const void *base_addr, int dummy); - /// Copy constructor (not implemented yet). - ACE_Based_Pointer (const ACE_Based_Pointer<CONCRETE> &); + ACE_Based_Pointer (const ACE_Based_Pointer &) = delete; + ACE_Based_Pointer (ACE_Based_Pointer &&) = delete; - /// Assignment operator. - void operator = (const ACE_Based_Pointer<CONCRETE> &); + void operator= (const ACE_Based_Pointer &); /// Pseudo-assignment operator. void operator = (CONCRETE *from); - /// The C++ "delegation operator". - CONCRETE *operator-> (void); + CONCRETE *operator-> (); }; ACE_END_VERSIONED_NAMESPACE_DECL diff --git a/ACE/ace/Based_Pointer_T.inl b/ACE/ace/Based_Pointer_T.inl index c9b00d5c703..2b2ff60ee34 100644 --- a/ACE/ace/Based_Pointer_T.inl +++ b/ACE/ace/Based_Pointer_T.inl @@ -5,16 +5,16 @@ ACE_BEGIN_VERSIONED_NAMESPACE_DECL template <class CONCRETE> ACE_INLINE CONCRETE * -ACE_Based_Pointer<CONCRETE>::operator->(void) +ACE_Based_Pointer<CONCRETE>::operator-> () { ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::operator->"); return reinterpret_cast<CONCRETE *> (ACE_COMPUTE_BASED_POINTER (this)); } template <class CONCRETE> ACE_INLINE void -ACE_Based_Pointer_Basic<CONCRETE>::operator = (CONCRETE *rhs) +ACE_Based_Pointer_Basic<CONCRETE>::operator= (CONCRETE *rhs) { - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator ="); + ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator="); if (rhs == 0) // Store a value of <target_> that indicate "NULL" pointer. this->target_ = -1; @@ -24,9 +24,9 @@ ACE_Based_Pointer_Basic<CONCRETE>::operator = (CONCRETE *rhs) } template <class CONCRETE> ACE_INLINE void -ACE_Based_Pointer<CONCRETE>::operator = (CONCRETE *rhs) +ACE_Based_Pointer<CONCRETE>::operator= (CONCRETE *rhs) { - ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::operator ="); + ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::operator="); if (rhs == 0) // Store a value of <target_> that indicate "NULL" pointer. this->target_ = -1; @@ -36,7 +36,7 @@ ACE_Based_Pointer<CONCRETE>::operator = (CONCRETE *rhs) } template <class CONCRETE> ACE_INLINE CONCRETE -ACE_Based_Pointer_Basic<CONCRETE>::operator *() const +ACE_Based_Pointer_Basic<CONCRETE>::operator * () const { ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator *"); return *reinterpret_cast<CONCRETE *> (ACE_COMPUTE_BASED_POINTER (this)); @@ -54,7 +54,7 @@ ACE_Based_Pointer_Basic<CONCRETE>::addr () const } template <class CONCRETE> ACE_INLINE -ACE_Based_Pointer_Basic<CONCRETE>::operator CONCRETE *() const +ACE_Based_Pointer_Basic<CONCRETE>::operator CONCRETE * () const { ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator CONCRETE *()"); @@ -62,72 +62,72 @@ ACE_Based_Pointer_Basic<CONCRETE>::operator CONCRETE *() const } template <class CONCRETE> ACE_INLINE CONCRETE -ACE_Based_Pointer_Basic<CONCRETE>::operator [] (int index) const +ACE_Based_Pointer_Basic<CONCRETE>::operator[] (int index) const { - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator []"); + ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator[]"); CONCRETE *c = reinterpret_cast<CONCRETE *> (ACE_COMPUTE_BASED_POINTER (this)); return c[index]; } template <class CONCRETE> ACE_INLINE void -ACE_Based_Pointer_Basic<CONCRETE>::operator += (int index) +ACE_Based_Pointer_Basic<CONCRETE>::operator+= (int index) { - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator +="); + ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator+="); this->base_offset_ += (index * sizeof (CONCRETE)); } template <class CONCRETE> ACE_INLINE bool -ACE_Based_Pointer_Basic<CONCRETE>::operator == (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const +ACE_Based_Pointer_Basic<CONCRETE>::operator== (const ACE_Based_Pointer_Basic &rhs) const { - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator =="); + ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator=="); return ACE_COMPUTE_BASED_POINTER (this) == ACE_COMPUTE_BASED_POINTER (&rhs); } template <class CONCRETE> ACE_INLINE bool -ACE_Based_Pointer_Basic<CONCRETE>::operator != (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const +ACE_Based_Pointer_Basic<CONCRETE>::operator!= (const ACE_Based_Pointer_Basic &rhs) const { - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator !="); + ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator!="); return !(*this == rhs); } template <class CONCRETE> ACE_INLINE bool -ACE_Based_Pointer_Basic<CONCRETE>::operator < (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const +ACE_Based_Pointer_Basic<CONCRETE>::operator< (const ACE_Based_Pointer_Basic &rhs) const { - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator <"); + ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator<"); return ACE_COMPUTE_BASED_POINTER (this) < ACE_COMPUTE_BASED_POINTER (&rhs); } template <class CONCRETE> ACE_INLINE bool -ACE_Based_Pointer_Basic<CONCRETE>::operator <= (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const +ACE_Based_Pointer_Basic<CONCRETE>::operator<= (const ACE_Based_Pointer_Basic &rhs) const { - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator <="); + ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator<="); return ACE_COMPUTE_BASED_POINTER (this) <= ACE_COMPUTE_BASED_POINTER (&rhs); } template <class CONCRETE> ACE_INLINE bool -ACE_Based_Pointer_Basic<CONCRETE>::operator > (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const +ACE_Based_Pointer_Basic<CONCRETE>::operator> (const ACE_Based_Pointer_Basic &rhs) const { - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator >"); + ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator>"); return ACE_COMPUTE_BASED_POINTER (this) > ACE_COMPUTE_BASED_POINTER (&rhs); } template <class CONCRETE> ACE_INLINE bool -ACE_Based_Pointer_Basic<CONCRETE>::operator >= (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) const +ACE_Based_Pointer_Basic<CONCRETE>::operator>= (const ACE_Based_Pointer_Basic &rhs) const { - ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator >="); + ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator>="); return ACE_COMPUTE_BASED_POINTER (this) >= ACE_COMPUTE_BASED_POINTER (&rhs); } template <class CONCRETE> ACE_INLINE void -ACE_Based_Pointer_Basic<CONCRETE>::operator= (const ACE_Based_Pointer_Basic<CONCRETE> &rhs) +ACE_Based_Pointer_Basic<CONCRETE>::operator= (const ACE_Based_Pointer_Basic &rhs) { ACE_TRACE ("ACE_Based_Pointer_Basic<CONCRETE>::operator="); *this = rhs.addr (); } template <class CONCRETE> ACE_INLINE void -ACE_Based_Pointer<CONCRETE>::operator= (const ACE_Based_Pointer<CONCRETE> &rhs) +ACE_Based_Pointer<CONCRETE>::operator= (const ACE_Based_Pointer &rhs) { ACE_TRACE ("ACE_Based_Pointer<CONCRETE>::operator="); *this = rhs.addr (); diff --git a/ACE/ace/Malloc.h b/ACE/ace/Malloc.h index 80cdcbf7421..06cc550c507 100644 --- a/ACE/ace/Malloc.h +++ b/ACE/ace/Malloc.h @@ -287,8 +287,6 @@ public: void dump () const; }; - using MALLOC_HEADER_PTR = ACE_Malloc_Header *; - /** * @class ACE_Name_Node * diff --git a/ACE/ace/Malloc_T.cpp b/ACE/ace/Malloc_T.cpp index 47d9126e96a..3d6a11a61cc 100644 --- a/ACE/ace/Malloc_T.cpp +++ b/ACE/ace/Malloc_T.cpp @@ -633,8 +633,8 @@ ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_malloc (size_t nbytes) (nbytes + sizeof (MALLOC_HEADER) - 1) / sizeof (MALLOC_HEADER) + 1; // Add one for the <MALLOC_HEADER> itself. - typename ACE_CB::MALLOC_HEADER_PTR prevp = 0; - typename ACE_CB::MALLOC_HEADER_PTR currp = 0; + MALLOC_HEADER *prevp = 0; + MALLOC_HEADER *currp = 0; ACE_SEH_TRY { @@ -671,7 +671,7 @@ ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_malloc (size_t nbytes) // allocate at tail end. ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nblocks_); currp->size_ -= nunits; - currp += static_cast<int> (currp->size_); + currp += currp->size_; MALLOC_HEADER::init_ptr (&currp->next_block_, 0, this->cb_ptr_); @@ -682,7 +682,7 @@ ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_malloc (size_t nbytes) // Skip over the MALLOC_HEADER when returning pointer. return currp + 1; } - else if (currp == this->cb_ptr_->freep_) + else if (currp == static_cast<MALLOC_HEADER *> (this->cb_ptr_->freep_)) { // We've wrapped around freelist without finding a // block. Therefore, we need to ask the memory pool for @@ -697,7 +697,7 @@ ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_malloc (size_t nbytes) if (remap_addr != 0) this->cb_ptr_ = (ACE_CB *) remap_addr; - if (currp) + if (currp != 0) { ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nblocks_); ACE_MALLOC_STATS (++this->cb_ptr_->malloc_stats_.nchunks_); @@ -787,8 +787,8 @@ ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_free (void *ap) return; // Adjust AP to point to the block MALLOC_HEADER - typename ACE_CB::MALLOC_HEADER_PTR blockp = ((MALLOC_HEADER *) ap) - 1; - typename ACE_CB::MALLOC_HEADER_PTR currp = this->cb_ptr_->freep_; + MALLOC_HEADER *blockp = ((MALLOC_HEADER *) ap) - 1; + MALLOC_HEADER *currp = this->cb_ptr_->freep_; // Search until we find the location where the blocks belongs. Note // that addresses are kept in sorted order. @@ -797,20 +797,18 @@ ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_free (void *ap) { for (; blockp <= currp - || blockp >= currp->next_block_; + || blockp >= (MALLOC_HEADER *) currp->next_block_; currp = currp->next_block_) { - if (currp >= currp->next_block_ + if (currp >= (MALLOC_HEADER *) currp->next_block_ && (blockp > currp - || blockp < currp->next_block_)) + || blockp < (MALLOC_HEADER *) currp->next_block_)) // Freed block at the start or the end of the memory pool. break; } // Join to upper neighbor. - typename ACE_CB::MALLOC_HEADER_PTR next = blockp; - next += static_cast<int> (blockp->size_); // ACE_Based_Pointer has += but not + - if (next == currp->next_block_) + if (blockp + blockp->size_ == static_cast<MALLOC_HEADER *> (currp->next_block_)) { ACE_MALLOC_STATS (--this->cb_ptr_->malloc_stats_.nblocks_); blockp->size_ += currp->next_block_->size_; @@ -820,9 +818,7 @@ ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::shared_free (void *ap) blockp->next_block_ = currp->next_block_; // Join to lower neighbor. - next = currp; - next += static_cast<int> (currp->size_); - if (next == blockp) + if ((currp + currp->size_) == blockp) { ACE_MALLOC_STATS (--this->cb_ptr_->malloc_stats_.nblocks_); currp->size_ += blockp->size_; |