mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 01:37:00 +00:00
Some missing from merge.
Signed-off-by: Salja <salja2012@hotmail.de>
This commit is contained in:
parent
ec939a5bce
commit
f4be15a7af
1895 changed files with 160408 additions and 53601 deletions
|
|
@ -1,3 +1,5 @@
|
|||
// $Id: CDR_Stream.cpp 96411 2012-11-29 10:31:26Z johnnyw $
|
||||
|
||||
#include "ace/CDR_Stream.h"
|
||||
#include "ace/SString.h"
|
||||
#include "ace/Auto_Ptr.h"
|
||||
|
|
@ -1520,15 +1522,9 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x)
|
|||
// the memory is allocated.
|
||||
if (len > 0 && len <= this->length())
|
||||
{
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_ALLOCATOR_RETURN (x,
|
||||
static_cast<ACE_CDR::Char*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::Char) * (len))),
|
||||
0);
|
||||
#else
|
||||
ACE_NEW_RETURN (x,
|
||||
ACE_CDR::Char[len],
|
||||
0);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
|
||||
ACE_Auto_Basic_Array_Ptr<ACE_CDR::Char> safe_data (x);
|
||||
|
||||
|
|
@ -1542,16 +1538,9 @@ ACE_InputCDR::read_string (ACE_CDR::Char *&x)
|
|||
{
|
||||
// Convert any null strings to empty strings since empty
|
||||
// strings can cause crashes. (See bug 58.)
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_ALLOCATOR_RETURN (x,
|
||||
static_cast<ACE_CDR::Char*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::Char) * (1))),
|
||||
0);
|
||||
#else
|
||||
ACE_NEW_RETURN (x,
|
||||
ACE_CDR::Char[1],
|
||||
0);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
|
||||
ACE_OS::strcpy (const_cast<char *&> (x), "");
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1614,15 +1603,9 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
|
|||
ACE_OutputCDR::wchar_maxbytes_);
|
||||
|
||||
//allocating one extra for the null character needed by applications
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_ALLOCATOR_RETURN (x,
|
||||
static_cast<ACE_CDR::WChar*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::WChar) * (len + 1))),
|
||||
0);
|
||||
#else
|
||||
ACE_NEW_RETURN (x,
|
||||
ACE_CDR::WChar [len + 1],
|
||||
false);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
|
||||
ACE_auto_ptr_reset (safe_data, x);
|
||||
|
||||
|
|
@ -1641,15 +1624,9 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
|
|||
}
|
||||
else
|
||||
{
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_ALLOCATOR_RETURN (x,
|
||||
static_cast<ACE_CDR::WChar*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::WChar) * (len))),
|
||||
0);
|
||||
#else
|
||||
ACE_NEW_RETURN (x,
|
||||
ACE_CDR::WChar [len],
|
||||
false);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
|
||||
ACE_auto_ptr_reset (safe_data, x);
|
||||
|
||||
|
|
@ -1665,16 +1642,9 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
|
|||
{
|
||||
// Convert any null strings to empty strings since empty
|
||||
// strings can cause crashes. (See bug 58.)
|
||||
#if defined (ACE_HAS_ALLOC_HOOKS)
|
||||
ACE_ALLOCATOR_RETURN (x,
|
||||
static_cast<ACE_CDR::WChar*> (ACE_Allocator::instance()->malloc(sizeof (ACE_CDR::WChar) * (1))),
|
||||
0);
|
||||
#else
|
||||
ACE_NEW_RETURN (x,
|
||||
ACE_CDR::WChar [1],
|
||||
false);
|
||||
#endif /* ACE_HAS_ALLOC_HOOKS */
|
||||
|
||||
ACE_NEW_RETURN (x,
|
||||
ACE_CDR::WChar[1],
|
||||
false);
|
||||
x[0] = '\x00';
|
||||
return true;
|
||||
}
|
||||
|
|
@ -1684,146 +1654,6 @@ ACE_InputCDR::read_wstring (ACE_CDR::WChar*& x)
|
|||
return false;
|
||||
}
|
||||
|
||||
// As of C++11 std::string guarantees contiguous memory storage.
|
||||
// That provides the opportunity to optimize CDR streaming.
|
||||
ACE_CDR::Boolean
|
||||
ACE_InputCDR::read_string (std::string& x)
|
||||
{
|
||||
#if defined (ACE_HAS_CPP11)
|
||||
// @@ This is a slight violation of "Optimize for the common case",
|
||||
// i.e. normally the translator will be 0, but OTOH the code is
|
||||
// smaller and should be better for the cache ;-) ;-)
|
||||
if (this->char_translator_ != 0)
|
||||
{
|
||||
this->good_bit_ = this->char_translator_->read_string (*this, x);
|
||||
return this->good_bit_;
|
||||
}
|
||||
|
||||
ACE_CDR::ULong len = 0;
|
||||
|
||||
if (!this->read_ulong (len))
|
||||
return false;
|
||||
|
||||
// A check for the length being too great is done later in the
|
||||
// call to read_char_array but we want to have it done before
|
||||
// the memory is allocated.
|
||||
if (len > 0 && len <= this->length())
|
||||
{
|
||||
try
|
||||
{
|
||||
x.resize (len-1); // no need to include the terminating '\0' here
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (len == 0 || this->read_char_array (&x[0], len-1))
|
||||
{
|
||||
return this->skip_char (); // skip the terminating '\0'
|
||||
}
|
||||
}
|
||||
|
||||
this->good_bit_ = false;
|
||||
x.clear ();
|
||||
return false;
|
||||
#else
|
||||
ACE_CDR::Char *buf = 0;
|
||||
ACE_CDR::Boolean const marshal_flag = this->read_string (buf);
|
||||
x.assign (buf);
|
||||
ACE::strdelete (buf);
|
||||
return marshal_flag;
|
||||
#endif
|
||||
}
|
||||
|
||||
#if !defined(ACE_LACKS_STD_WSTRING)
|
||||
ACE_CDR::Boolean
|
||||
ACE_InputCDR::read_wstring (std::wstring& x)
|
||||
{
|
||||
#if defined (ACE_HAS_CPP11)
|
||||
// @@ This is a slight violation of "Optimize for the common case",
|
||||
// i.e. normally the translator will be 0, but OTOH the code is
|
||||
// smaller and should be better for the cache ;-) ;-)
|
||||
if (this->wchar_translator_ != 0)
|
||||
{
|
||||
this->good_bit_ = this->wchar_translator_->read_wstring (*this, x);
|
||||
return this->good_bit_;
|
||||
}
|
||||
if (ACE_OutputCDR::wchar_maxbytes_ == 0)
|
||||
{
|
||||
errno = EACCES;
|
||||
return (this->good_bit_ = false);
|
||||
}
|
||||
|
||||
ACE_CDR::ULong len = 0;
|
||||
|
||||
if (!this->read_ulong (len))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// A check for the length being too great is done later in the
|
||||
// call to read_char_array but we want to have it done before
|
||||
// the memory is allocated.
|
||||
if (len > 0 && len <= this->length ())
|
||||
{
|
||||
if (static_cast<ACE_CDR::Short> (this->major_version_) == 1
|
||||
&& static_cast<ACE_CDR::Short> (this->minor_version_) == 2)
|
||||
{
|
||||
len /=
|
||||
ACE_Utils::truncate_cast<ACE_CDR::ULong> (
|
||||
ACE_OutputCDR::wchar_maxbytes_);
|
||||
|
||||
try
|
||||
{
|
||||
x.resize (len);
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this->read_wchar_array (&x[0], len))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
x.resize (len-1); // no need to include the terminating '\0' here
|
||||
}
|
||||
catch (const std::bad_alloc&)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (len == 1 || this->read_wchar_array (&x[0], len-1))
|
||||
{
|
||||
return this->skip_wchar (); // skip the terminating '\0'
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (len == 0)
|
||||
{
|
||||
x.clear ();
|
||||
return true;
|
||||
}
|
||||
|
||||
this->good_bit_ = false;
|
||||
x.clear ();
|
||||
return false;
|
||||
#else
|
||||
ACE_CDR::WChar *buf = 0;
|
||||
ACE_CDR::Boolean const marshal_flag = this->read_wstring (buf);
|
||||
x.assign (buf);
|
||||
ACE::strdelete (buf);
|
||||
return marshal_flag;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
ACE_CDR::Boolean
|
||||
ACE_InputCDR::read_array (void* x,
|
||||
size_t size,
|
||||
|
|
@ -2367,36 +2197,12 @@ ACE_Char_Codeset_Translator::~ACE_Char_Codeset_Translator (void)
|
|||
{
|
||||
}
|
||||
|
||||
ACE_CDR::Boolean
|
||||
ACE_Char_Codeset_Translator::read_string (ACE_InputCDR &cdr,
|
||||
std::string &x)
|
||||
{
|
||||
ACE_CDR::Char *buf = 0;
|
||||
ACE_CDR::Boolean const marshal_flag = this->read_string (cdr, buf);
|
||||
x.assign (buf);
|
||||
ACE::strdelete (buf);
|
||||
return marshal_flag;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
ACE_WChar_Codeset_Translator::~ACE_WChar_Codeset_Translator (void)
|
||||
{
|
||||
}
|
||||
|
||||
#if !defined(ACE_LACKS_STD_WSTRING)
|
||||
ACE_CDR::Boolean
|
||||
ACE_WChar_Codeset_Translator::read_wstring (ACE_InputCDR &cdr,
|
||||
std::wstring &x)
|
||||
{
|
||||
ACE_CDR::WChar *buf = 0;
|
||||
ACE_CDR::Boolean const marshal_flag = this->read_wstring (cdr, buf);
|
||||
x.assign (buf);
|
||||
ACE::strdelete (buf);
|
||||
return marshal_flag;
|
||||
}
|
||||
#endif
|
||||
|
||||
// --------------------------------------------------------------
|
||||
|
||||
ACE_CDR::Boolean
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue