summaryrefslogtreecommitdiff
path: root/TAO/tao/Sequence.i
diff options
context:
space:
mode:
authorcoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-08-27 02:09:49 +0000
committercoryan <coryan@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-08-27 02:09:49 +0000
commitae45d29dd1e817e1a60628d26213611bf777d712 (patch)
treea452eb38b0706749c5cf99ef5b72c40373a27ec6 /TAO/tao/Sequence.i
parent2fd3a3beab0ab23616986568df68de9682fe81b5 (diff)
downloadATCD-ae45d29dd1e817e1a60628d26213611bf777d712.tar.gz
ChangeLogTag:Wed Aug 26 19:13:49 1998 Carlos O'Ryan <coryan@cs.wustl.edu>
Diffstat (limited to 'TAO/tao/Sequence.i')
-rw-r--r--TAO/tao/Sequence.i52
1 files changed, 52 insertions, 0 deletions
diff --git a/TAO/tao/Sequence.i b/TAO/tao/Sequence.i
index 93f5f40c6cd..4fdad1f141c 100644
--- a/TAO/tao/Sequence.i
+++ b/TAO/tao/Sequence.i
@@ -268,6 +268,58 @@ TAO_Unbounded_Sequence<CORBA::Octet>::get_buffer (void) const
return ACE_reinterpret_cast(const CORBA::Octet * ACE_CAST_CONST, this->buffer_);
}
+// This function is a little too big to be inlined, but some compilers
+// (Sun/CC 4.1?) die if it isn't :-(
+ACE_INLINE CORBA::Octet *
+TAO_Unbounded_Sequence<CORBA::Octet>::get_buffer (CORBA::Boolean orphan)
+{
+ CORBA::Octet *result = 0;
+ if (orphan == CORBA::B_FALSE)
+ {
+ // We retain ownership.
+
+ if (this->buffer_ == 0)
+ {
+ // The buffer was not allocated, we must allocate it now.
+ result = TAO_Unbounded_Sequence<CORBA::Octet>::allocbuf (this->length_);
+ this->buffer_ = result;
+ }
+ else
+ {
+ result =
+ ACE_reinterpret_cast (CORBA::Octet*,this->buffer_);
+ }
+ }
+ else if (this->mb_ != 0) // (orphan == CORBA::B_TRUE)
+ {
+ // We must create a copy anyway:
+ // the user is supposed to call freebuf() to release the
+ // buffer, but the buffer is inside a Message_Block...
+ // We thought about storing the pointer to the Message_Block
+ // somewhere at the beginning of the buffer (before the actual
+ // data), but that will not work in 64 bit machines when the
+ // buffer comes from a CDR stream.
+ //
+ result = TAO_Unbounded_Sequence<CORBA::Octet>::allocbuf (this->length_);
+ ACE_OS::memcpy (result, this->buffer_, this->length_);
+ }
+ else if (this->release_ != CORBA::B_FALSE)
+ {
+ // We set the state back to default and relinquish
+ // ownership.
+ result = ACE_reinterpret_cast(CORBA::Octet*,this->buffer_);
+ this->maximum_ = 0;
+ this->length_ = 0;
+ this->buffer_ = 0;
+ this->release_ = CORBA::B_FALSE;
+ }
+ /* else
+ // Oops, it's not our buffer to relinquish...
+ return 0;
+ */
+ return result;
+}
+
ACE_INLINE CORBA::Octet &
TAO_Unbounded_Sequence<CORBA::Octet>::operator[] (CORBA::ULong i)
{