From d5260da6dabfc89a24062f8815cb76d33de634c8 Mon Sep 17 00:00:00 2001 From: Ossama Othman Date: Wed, 10 Dec 2003 21:16:18 +0000 Subject: ChangeLogTag:Wed Dec 10 13:16:03 2003 Ossama Othman --- ChangeLog | 8 +++ ace/UUID.cpp | 190 ++++++++++++++++++++++++++++++----------------------------- 2 files changed, 106 insertions(+), 92 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0b4c0dccb07..af61833a293 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Wed Dec 10 13:16:03 2003 Ossama Othman + + * ace/UUID.cpp (to_string): + + Fixed incorrect delete() operator call. Use vector delete[]() + instead of scalar delete() since array was allocated with + new[](). + Wed Dec 10 15:09:13 UTC 2003 Johnny Willemsen * examples/TMCast/Member/member.cpp: diff --git a/ace/UUID.cpp b/ace/UUID.cpp index f168596678b..de88258d1b6 100644 --- a/ace/UUID.cpp +++ b/ace/UUID.cpp @@ -13,6 +13,7 @@ #include "ace/OS_NS_sys_time.h" #include "ace/OS_NS_netdb.h" #include "ace/OS_NS_unistd.h" +#include "ace/ACE.h" ACE_RCSID (ace, UUID, @@ -78,7 +79,7 @@ namespace ACE_Utils node_release_ = 1; - if (uuid_string.length() < NIL_UUID.to_string()->length()) + if (uuid_string.length() < NIL_UUID.to_string ()->length ()) { ACE_DEBUG ((LM_DEBUG, "%N ACE_UUID::UUID - " @@ -87,10 +88,10 @@ namespace ACE_Utils } /// Special case for the nil UUID. - if (uuid_string == *NIL_UUID.to_string()) + if (uuid_string == *NIL_UUID.to_string ()) { bool copy_constructor_not_supported = false; - ACE_ASSERT(copy_constructor_not_supported); + ACE_ASSERT (copy_constructor_not_supported); //*this = NIL_UUID; ACE_UNUSED_ARG (copy_constructor_not_supported); return; @@ -106,58 +107,62 @@ namespace ACE_Utils if (uuid_string.length() == NIL_UUID.to_string()->length()) { - // This might seem quite strange this being in ACE, but it seems to - // be a bit difficult to write a facade for ::sscanf because some - // compilers dont support vsscanf, including MSVC. It appears that - // most platforms support sscanf though so we need to use it - // directly. - int nScanned = ::sscanf(uuid_string.c_str(), - "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x", - &timeLow, - &timeMid, - &timeHiAndVersion, - &clockSeqHiAndReserved, - &clockSeqLow, - &node[0], - &node[1], - &node[2], - &node[3], - &node[4], - &node[5] - ); - if (nScanned != 11) - { - ACE_DEBUG ((LM_DEBUG, - "UUID::UUID - " - "IllegalArgument(invalid string representation)")); - return; - } - } - else - { - int nScanned = ::sscanf(uuid_string.c_str(), - "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s", - &timeLow, - &timeMid, - &timeHiAndVersion, - &clockSeqHiAndReserved, - &clockSeqLow, - &node[0], - &node[1], - &node[2], - &node[3], - &node[4], - &node[5], - thr_pid_buf - ); - if (nScanned != 12) - { - ACE_DEBUG ((LM_DEBUG, - "ACE_UUID::ACE_UUID - " - "IllegalArgument(invalid string representation)")); - return; - } - } + // This might seem quite strange this being in ACE, but it + // seems to be a bit difficult to write a facade for ::sscanf + // because some compilers dont support vsscanf, including + // MSVC. It appears that most platforms support sscanf though + // so we need to use it directly. + const int nScanned = + ::sscanf(uuid_string.c_str(), + "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x", + &timeLow, + &timeMid, + &timeHiAndVersion, + &clockSeqHiAndReserved, + &clockSeqLow, + &node[0], + &node[1], + &node[2], + &node[3], + &node[4], + &node[5] + ); + + if (nScanned != 11) + { + ACE_DEBUG ((LM_DEBUG, + "UUID::UUID - " + "IllegalArgument(invalid string representation)")); + return; + } + } + else + { + const int nScanned = + ::sscanf (uuid_string.c_str(), + "%8x-%4x-%4x-%2x%2x-%2x%2x%2x%2x%2x%2x-%s", + &timeLow, + &timeMid, + &timeHiAndVersion, + &clockSeqHiAndReserved, + &clockSeqLow, + &node[0], + &node[1], + &node[2], + &node[3], + &node[4], + &node[5], + thr_pid_buf + ); + + if (nScanned != 12) + { + ACE_DEBUG ((LM_DEBUG, + "ACE_UUID::ACE_UUID - " + "IllegalArgument(invalid string representation)")); + return; + } + } this->timeLow_ = ACE_static_cast (ACE_UINT32, timeLow); this->timeMid_ = ACE_static_cast (ACE_UINT16, timeMid); @@ -234,54 +239,55 @@ namespace ACE_Utils char *buf; if ((thr_id_.length () != 0) && (pid_.length () != 0)) - { - UUID_STRING_LENGTH += 2; //for '-' - ACE_NEW_RETURN (buf, - char[UUID_STRING_LENGTH + 1], - 0); - - ACE_OS::sprintf(buf, - "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s", - this->timeLow_, - this->timeMid_, - this->timeHiAndVersion_, - this->clockSeqHiAndReserved_, - this->clockSeqLow_, - (this->node_->nodeID ()) [0], - (this->node_->nodeID ()) [1], - (this->node_->nodeID ()) [2], - (this->node_->nodeID ()) [3], - (this->node_->nodeID ()) [4], - (this->node_->nodeID ()) [5], - thr_id_.c_str (), - pid_.c_str () - ); - } - else { + UUID_STRING_LENGTH += 2; //for '-' ACE_NEW_RETURN (buf, char[UUID_STRING_LENGTH + 1], 0); ACE_OS::sprintf(buf, - "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x", + "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x-%s-%s", this->timeLow_, this->timeMid_, this->timeHiAndVersion_, this->clockSeqHiAndReserved_, this->clockSeqLow_, (this->node_->nodeID ()) [0], - (this->node_->nodeID ()) [1], + (this->node_->nodeID ()) [1], (this->node_->nodeID ()) [2], (this->node_->nodeID ()) [3], (this->node_->nodeID ()) [4], - (this->node_->nodeID ()) [5] + (this->node_->nodeID ()) [5], + thr_id_.c_str (), + pid_.c_str () ); } + else + { + ACE_NEW_RETURN (buf, + char[UUID_STRING_LENGTH + 1], + 0); + + ACE_OS::sprintf (buf, + "%8.8x-%4.4x-%4.4x-%2.2x%2.2x-%2.2x%2.2x%2.2x%2.2x%2.2x%2.2x", + this->timeLow_, + this->timeMid_, + this->timeHiAndVersion_, + this->clockSeqHiAndReserved_, + this->clockSeqLow_, + (this->node_->nodeID ()) [0], + (this->node_->nodeID ()) [1], + (this->node_->nodeID ()) [2], + (this->node_->nodeID ()) [3], + (this->node_->nodeID ()) [4], + (this->node_->nodeID ()) [5] + ); + } + ACE_NEW_RETURN (this->as_string_, ACE_CString (buf, UUID_STRING_LENGTH), 0); - delete buf; + delete [] buf; } return as_string_; @@ -291,7 +297,7 @@ namespace ACE_Utils : timeLast_ (0) { ACE_NEW (lock_, - ACE_SYNCH_MUTEX); + ACE_SYNCH_MUTEX); destroy_lock_ = 1; } @@ -311,14 +317,14 @@ namespace ACE_Utils UUID_node::NodeID nodeID; if (result != -1) { - ACE_DEBUG ((LM_DEBUG, - "%02X-%02X-%02X-%02X-%02X-%02X\n", - macaddress.node [0], - macaddress.node [1], - macaddress.node [2], - macaddress.node [3], - macaddress.node [4], - macaddress.node [5])); +// ACE_DEBUG ((LM_DEBUG, +// "%02X-%02X-%02X-%02X-%02X-%02X\n", +// macaddress.node [0], +// macaddress.node [1], +// macaddress.node [2], +// macaddress.node [3], +// macaddress.node [4], +// macaddress.node [5])); ACE_OS::memcpy (&nodeID, macaddress.node, -- cgit v1.2.1