summaryrefslogtreecommitdiff
path: root/ace/CDR_Stream.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/CDR_Stream.cpp')
-rw-r--r--ace/CDR_Stream.cpp55
1 files changed, 17 insertions, 38 deletions
diff --git a/ace/CDR_Stream.cpp b/ace/CDR_Stream.cpp
index 610c6f6e9e3..5bb165a0237 100644
--- a/ace/CDR_Stream.cpp
+++ b/ace/CDR_Stream.cpp
@@ -10,7 +10,6 @@
ACE_RCSID(ace, CDR_Stream, "$Id$")
-
// ****************************************************************
ACE_OutputCDR::ACE_OutputCDR (size_t size,
@@ -626,8 +625,7 @@ ACE_InputCDR::ACE_InputCDR (ACE_Data_Block *data,
ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs,
size_t size,
ACE_CDR::Long offset)
- : start_ (rhs.start_,
- ACE_CDR::MAX_ALIGNMENT),
+ : start_ (rhs.start_.data_block ()->duplicate ()),
do_byte_swap_ (rhs.do_byte_swap_),
good_bit_ (1),
char_translator_ (0),
@@ -635,16 +633,10 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs,
major_version_ (rhs.major_version_),
minor_version_ (rhs.minor_version_)
{
- // Align the base pointer assuming that the incoming stream is also
- // aligned the way we are aligned
- char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
- ACE_CDR::MAX_ALIGNMENT);
-
- size_t newpos =
- (rhs.start_.rd_ptr() - incoming_start) + offset;
-
- if (newpos <= this->start_.space ()
- && newpos + size <= this->start_.space ())
+ char* newpos = rhs.start_.rd_ptr() + offset;
+ if (this->start_.base () <= newpos
+ && newpos <= this->start_.end ()
+ && newpos + size <= this->start_.end ())
{
this->start_.rd_ptr (newpos);
this->start_.wr_ptr (newpos + size);
@@ -657,8 +649,7 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs,
ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs,
size_t size)
- : start_ (rhs.start_,
- ACE_CDR::MAX_ALIGNMENT),
+ : start_ (rhs.start_.data_block ()->duplicate ()),
do_byte_swap_ (rhs.do_byte_swap_),
good_bit_ (1),
char_translator_ (0),
@@ -666,16 +657,10 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs,
major_version_ (rhs.major_version_),
minor_version_ (rhs.minor_version_)
{
- // Align the base pointer assuming that the incoming stream is also
- // aligned the way we are aligned
- char *incoming_start = ACE_ptr_align_binary (rhs.start_.base (),
- ACE_CDR::MAX_ALIGNMENT);
-
- size_t newpos =
- rhs.start_.rd_ptr() - incoming_start;
-
- if (newpos <= this->start_.space ()
- && newpos + size <= this->start_.space ())
+ char* newpos = rhs.start_.rd_ptr();
+ if (this->start_.base () <= newpos
+ && newpos <= this->start_.end ()
+ && newpos + size <= this->start_.end ())
{
// Notice that ACE_Message_Block::duplicate may leave the
// wr_ptr() with a higher value that what we actually want.
@@ -693,8 +678,7 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs,
}
ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs)
- : start_ (rhs.start_,
- ACE_CDR::MAX_ALIGNMENT),
+ : start_ (rhs.start_.data_block ()->duplicate ()),
do_byte_swap_ (rhs.do_byte_swap_),
good_bit_ (1),
char_translator_ (rhs.char_translator_),
@@ -702,13 +686,8 @@ ACE_InputCDR::ACE_InputCDR (const ACE_InputCDR& rhs)
major_version_ (rhs.major_version_),
minor_version_ (rhs.minor_version_)
{
- char *buf = ACE_ptr_align_binary (rhs.start_.base (),
- ACE_CDR::MAX_ALIGNMENT);
-
- size_t rd_offset = rhs.start_.rd_ptr () - buf;
- size_t wr_offset = rhs.start_.wr_ptr () - buf;
- this->start_.rd_ptr (rd_offset);
- this->start_.wr_ptr (wr_offset);
+ this->start_.rd_ptr (rhs.start_.rd_ptr ());
+ this->start_.wr_ptr (rhs.start_.wr_ptr ());
}
ACE_InputCDR::ACE_InputCDR (ACE_InputCDR::Transfer_Contents x)
@@ -804,18 +783,18 @@ ACE_InputCDR::read_wchar (ACE_CDR::WChar& x)
return this->read_octet_array (
ACE_reinterpret_cast (ACE_CDR::Octet*,
&x),
- ACE_static_cast (ACE_CDR::ULong,
+ ACE_static_cast (ACE_CDR::ULong,
len)
);
}
}
else if (this->wchar_translator_ == 0)
{
- return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort*,
+ return this->read_2 (ACE_reinterpret_cast (ACE_CDR::UShort*,
&x));
}
- return this->wchar_translator_->read_wchar (*this,
+ return this->wchar_translator_->read_wchar (*this,
x);
}
@@ -827,7 +806,7 @@ ACE_InputCDR::read_string (char *&x)
// smaller and should be better for the cache ;-) ;-)
if (this->char_translator_ != 0)
{
- return this->char_translator_->read_string (*this,
+ return this->char_translator_->read_string (*this,
x);
}