summaryrefslogtreecommitdiff
path: root/TAO/tao/ORB.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'TAO/tao/ORB.cpp')
-rw-r--r--TAO/tao/ORB.cpp118
1 files changed, 74 insertions, 44 deletions
diff --git a/TAO/tao/ORB.cpp b/TAO/tao/ORB.cpp
index 40d6695310c..a829acc5d9f 100644
--- a/TAO/tao/ORB.cpp
+++ b/TAO/tao/ORB.cpp
@@ -79,27 +79,7 @@ int CORBA_ORB::orb_init_count_ = 0;
// Pointer to the "default ORB."
CORBA::ORB_ptr CORBA::instance_ = 0;
-CORBA_String_var::CORBA_String_var (char *p)
- : ptr_ (p)
-{
- // NOTE: According to the CORBA spec this string must *not* be
- // copied, but it is non-compliant to use it/release it in the
- // calling code. argument is consumed. p should never be NULL
-}
-
-CORBA_String_var::CORBA_String_var (const CORBA_String_var& r)
-{
- this->ptr_ = CORBA::string_dup (r.ptr_);
-}
-
-CORBA_String_var::~CORBA_String_var (void)
-{
- if (this->ptr_ != 0)
- {
- CORBA::string_free (this->ptr_);
- this->ptr_ = 0;
- }
-}
+// ****************************************************************
CORBA_ORB::InvalidName::InvalidName (void)
{
@@ -984,7 +964,7 @@ CORBA_ORB::create_stub_object (const TAO_ObjectKey &key,
CORBA::String id = 0;
if (type_id)
- id = CORBA::string_copy (type_id);
+ id = CORBA::string_dup (type_id);
TAO_Stub *stub = 0;
@@ -1115,22 +1095,37 @@ CORBA_ORB::create_dyn_enum (CORBA_TypeCode_ptr tc,
#endif /* TAO_HAS_MINIMUM_CORBA */
+// ****************************************************************
+
// String utility support; this needs to be integrated with the ORB's
// own memory allocation subsystem.
-CORBA::String
+CORBA::Char*
CORBA::string_copy (const CORBA::Char *str)
{
- if (!str)
- return 0;
+ return CORBA::string_dup (str);
+}
- size_t len = ACE_OS::strlen (str);
+CORBA_String_var::CORBA_String_var (char *p)
+ : ptr_ (p)
+{
+ // NOTE: According to the CORBA spec this string must *not* be
+ // copied, but it is non-compliant to use it/release it in the
+ // calling code. argument is consumed. p should never be NULL
+}
- // This allocates an extra byte for the '\0';
- CORBA::String copy = CORBA::string_alloc (len);
+CORBA_String_var::CORBA_String_var (const CORBA_String_var& r)
+{
+ this->ptr_ = CORBA::string_dup (r.ptr_);
+}
- ACE_OS::memcpy (copy, str, len + 1);
- return copy;
+CORBA_String_var::~CORBA_String_var (void)
+{
+ if (this->ptr_ != 0)
+ {
+ CORBA::string_free (this->ptr_);
+ this->ptr_ = 0;
+ }
}
CORBA_String_var &
@@ -1167,31 +1162,66 @@ CORBA_String_var::operator= (const CORBA_String_var& r)
return *this;
}
-// Wide Character string utility support; this can need to be
-// integrated with the ORB's own memory allocation subsystem.
+// ****************************************************************
-CORBA::WString
-CORBA::wstring_alloc (CORBA::ULong len)
+CORBA_WString_var::CORBA_WString_var (CORBA::WChar *p)
+ : ptr_ (p)
{
- return new CORBA::WChar [(size_t) (len + 1)];
+ // NOTE: According to the CORBA spec this string must *not* be
+ // copied, but it is non-compliant to use it/release it in the
+ // calling code. argument is consumed. p should never be NULL
}
-CORBA::WString
-CORBA::wstring_copy (const CORBA::WChar *const str)
+CORBA_WString_var::CORBA_WString_var (const CORBA_WString_var& r)
{
- if (!str)
- return 0;
+ this->ptr_ = CORBA::wstring_dup (r.ptr_);
+}
- CORBA::WString retval = CORBA::wstring_alloc (ACE_OS::wslen (str));
- return ACE_OS::wscpy (retval, str);
+CORBA_WString_var::~CORBA_WString_var (void)
+{
+ if (this->ptr_ != 0)
+ {
+ CORBA::wstring_free (this->ptr_);
+ this->ptr_ = 0;
+ }
}
-void
-CORBA::wstring_free (CORBA::WChar *const str)
+CORBA_WString_var &
+CORBA_WString_var::operator= (CORBA::WChar *p)
{
- delete [] str;
+ if (this->ptr_ != p)
+ {
+ if (this->ptr_ != 0)
+ CORBA::wstring_free (this->ptr_);
+ this->ptr_ = p;
+ }
+ return *this;
+}
+
+CORBA_WString_var &
+CORBA_WString_var::operator= (const CORBA::WChar *p)
+{
+ if (this->ptr_ != 0)
+ CORBA::wstring_free (this->ptr_);
+
+ this->ptr_ = CORBA::wstring_dup (p);
+ return *this;
}
+CORBA_WString_var &
+CORBA_WString_var::operator= (const CORBA_WString_var& r)
+{
+ if (this != &r)
+ {
+ if (this->ptr_ != 0)
+ CORBA::wstring_free (this->ptr_);
+ this->ptr_ = CORBA::wstring_dup (r.ptr_);
+ }
+ return *this;
+}
+
+// ****************************************************************
+
void
CORBA_ORB::init_orb_globals (CORBA::Environment &ACE_TRY_ENV)
{