summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOssama Othman <ossama-othman@users.noreply.github.com>2005-10-19 17:07:57 +0000
committerOssama Othman <ossama-othman@users.noreply.github.com>2005-10-19 17:07:57 +0000
commit82dfcc4c59bd22f4cdf7e34cbf4c49de045a14bc (patch)
tree712a7fa3758fe01a357c39ce311b65ed55ed61b0
parente9ea4c76391ae6614ab828fe33a781edfe759967 (diff)
downloadATCD-82dfcc4c59bd22f4cdf7e34cbf4c49de045a14bc.tar.gz
ChangeLogTag:Wed Oct 19 10:01:03 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
-rw-r--r--TAO/ChangeLog13
-rw-r--r--TAO/tao/Valuetype/Value_VarOut_T.cpp20
2 files changed, 21 insertions, 12 deletions
diff --git a/TAO/ChangeLog b/TAO/ChangeLog
index ec8f53d13e7..7aa063a68a4 100644
--- a/TAO/ChangeLog
+++ b/TAO/ChangeLog
@@ -1,3 +1,16 @@
+Wed Oct 19 10:01:03 2005 Ossama Othman <ossama@dre.vanderbilt.edu>
+
+ * tao/Valuetype/Value_VarOut_T.cpp (operator=):
+
+ Implement assignment operators in terms of their constructor
+ counterparts using the canonical copy and (non-throwing) swap
+ technique. Provides strong exception safety guarantee, obviates
+ need for self-assignment check and reduces code duplication
+ between constructors and assignment operators. This change also
+ reverts "Tue Jun 21 13:38:23 2005 Gary Maxey <gary.maxey@...>",
+ and fixes a memory leak reported by Mickael P. Golovin <migel at
+ garant dot ru>.
+
Wed Oct 19 12:57:12 UTC 2005 Johnny Willemsen <jwillemsen@remedy.nl>
* tao/Messaging/ExceptionHolder_i.cpp:
diff --git a/TAO/tao/Valuetype/Value_VarOut_T.cpp b/TAO/tao/Valuetype/Value_VarOut_T.cpp
index 884ec566468..1640adeabba 100644
--- a/TAO/tao/Valuetype/Value_VarOut_T.cpp
+++ b/TAO/tao/Valuetype/Value_VarOut_T.cpp
@@ -6,6 +6,7 @@
#include "tao/Valuetype/Value_VarOut_T.h"
#include "tao/Valuetype/Value_CORBA_methods.h"
+#include <algorithm> /* For std::swap<>() */
template<typename T>
void
@@ -70,23 +71,18 @@ template <typename T>
TAO_Value_Var_T<T> &
TAO_Value_Var_T<T>::operator= (T * p)
{
- TAO::Value_Traits<T>::remove_ref (this->ptr_);
- this->ptr_ = p;
- TAO::Value_Traits<T>::add_ref (p);
+ TAO_Value_Var_T<T> tmp (p);
+ std::swap (this->ptr_, tmp.ptr_);
+
return *this;
}
template <typename T>
TAO_Value_Var_T<T> &
-TAO_Value_Var_T<T>::operator= (const TAO_Value_Var_T & p)
-{
- if (this != &p)
- {
- TAO::Value_Traits<T>::remove_ref (this->ptr_);
- T * tmp = p.ptr ();
- TAO::Value_Traits<T>::add_ref (tmp);
- this->ptr_ = tmp;
- }
+TAO_Value_Var_T<T>::operator= (const TAO_Value_Var_T<T> & p)
+{
+ TAO_Value_Var_T<T> tmp (p);
+ std::swap (this->ptr_, tmp.ptr_);
return *this;
}