diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-03-21 03:28:45 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1998-03-21 03:28:45 +0000 |
commit | 347a5ae4b5f7f0e4b135ff1a467c3c4f8115b41b (patch) | |
tree | 472f5bff18b6eb4af6ef7400d052945f86d2bf8b | |
parent | 794a7bb2ed4a58d482d58f56405cd5c6c18e88ef (diff) | |
download | ATCD-347a5ae4b5f7f0e4b135ff1a467c3c4f8115b41b.tar.gz |
*** empty log message ***
-rw-r--r-- | TAO/tao/sequence.i | 6 | ||||
-rw-r--r-- | TAO/tao/sequence_T.cpp | 20 | ||||
-rw-r--r-- | TAO/tao/sequence_T.i | 50 |
3 files changed, 63 insertions, 13 deletions
diff --git a/TAO/tao/sequence.i b/TAO/tao/sequence.i index 989a125ccca..c701feb63b2 100644 --- a/TAO/tao/sequence.i +++ b/TAO/tao/sequence.i @@ -14,21 +14,21 @@ // // ============================================================================ -// operations on the unbounded sequence class +// Operations on the unbounded sequence class. ACE_INLINE TAO_Base_Sequence::TAO_Base_Sequence (void) : maximum_ (0), length_ (0), buffer_ (0), - release_ (0) + release_ (CORBA::B_FALSE) { } ACE_INLINE TAO_Base_Sequence::TAO_Base_Sequence (CORBA::ULong maximum, CORBA::ULong length, - void* buffer, + void *buffer, CORBA::Boolean release) : maximum_ (maximum), length_ (length), diff --git a/TAO/tao/sequence_T.cpp b/TAO/tao/sequence_T.cpp index cffd306fdad..fa3190efe07 100644 --- a/TAO/tao/sequence_T.cpp +++ b/TAO/tao/sequence_T.cpp @@ -286,10 +286,12 @@ operator= (const TAO_Unbounded_Object_Sequence<T> &rhs) return *this; } -template <class T> T* * +template <class T> T ** TAO_Unbounded_Object_Sequence<T>::allocbuf (CORBA::ULong nelems) { - T **buf = new T*[nelems]; + T **buf; + + ACE_NEW_RETURN (buf, T*[nelems], 0); for (CORBA::ULong i = 0; i < nelems; i++) buf[i] = T::_nil (); @@ -437,12 +439,16 @@ TAO_Bounded_Object_Sequence<T, MAX>::operator= return *this; } -template <class T, CORBA::ULong MAX> T* * +template <class T, CORBA::ULong MAX> T ** TAO_Bounded_Object_Sequence<T, MAX>::allocbuf (CORBA::ULong) { - T **buf = new T*[MAX]; + T **buf; + + ACE_NEW_RETURN (buf, T*[MAX], 0) + for (CORBA::ULong i = 0; i < MAX; i++) buf[i] = T::_nil (); + return buf; } @@ -561,10 +567,12 @@ TAO_Bounded_String_Sequence<MAX>::operator= return *this; } -template<CORBA::ULong MAX> char* * +template<CORBA::ULong MAX> char ** TAO_Bounded_String_Sequence<MAX>::allocbuf (CORBA::ULong) { - char **buf = new char*[MAX]; + char **buf; + + ACE_NEW_RETURN (buf, char *[MAX], 0); for (CORBA::ULong i = 0; i < MAX; i++) buf[i] = 0; diff --git a/TAO/tao/sequence_T.i b/TAO/tao/sequence_T.i index e63edc252d0..cd70aa05a97 100644 --- a/TAO/tao/sequence_T.i +++ b/TAO/tao/sequence_T.i @@ -29,7 +29,28 @@ TAO_Unbounded_Sequence<T>::TAO_Unbounded_Sequence (void) template <class T> ACE_INLINE T * TAO_Unbounded_Sequence<T>::get_buffer (CORBA::Boolean orphan) { - // @@ This is broken... + if (orphan == CORBA::B_FALSE) + { + // We retain ownership. + + if (this->buffer_ == 0) + this->buffer_ = (void *) new T[this->length_]; + } + else // if (orphan == CORBA::B_TRUE) + { + if (this->release_ == CORBA::B_FALSE) + // Oops, it's not our buffer to relinquish... + return 0; + else + { + // We set the state back to default and relinquish + // ownership. + this->maximum_ = 0; + this->length_ = 0; + this->buffer_ = 0; + this->release_ = CORBA::B_FALSE; + } + } return (T *) this->buffer_; } @@ -88,7 +109,7 @@ TAO_Unbounded_Sequence<T>::allocbuf (CORBA::ULong size) template <class T> ACE_INLINE void TAO_Unbounded_Sequence<T>::freebuf (T *buffer) { - delete[] buffer; + delete [] buffer; } // *************************************************** @@ -98,7 +119,28 @@ TAO_Unbounded_Sequence<T>::freebuf (T *buffer) template <class T, CORBA::ULong MAX> ACE_INLINE T * TAO_Bounded_Sequence<T, MAX>::get_buffer (CORBA::Boolean orphan) { - // @@ This is broken... + if (orphan == CORBA::B_FALSE) + { + // We retain ownership. + + if (this->buffer_ == 0) + this->buffer_ = (void *) new T[this->maximum_]; + } + else // if (orphan == CORBA::B_TRUE) + { + if (this->release_ == CORBA::B_FALSE) + // Oops, it's not our buffer to relinquish... + return 0; + else + { + // We set the state back to default and relinquish + // ownership. + this->maximum_ = 0; + this->length_ = 0; + this->buffer_ = 0; + this->release_ = CORBA::B_FALSE; + } + } return (T *) this->buffer_; } @@ -154,7 +196,7 @@ TAO_Bounded_Sequence<T, MAX>::allocbuf (CORBA::ULong) template <class T, CORBA::ULong MAX> ACE_INLINE void TAO_Bounded_Sequence<T, MAX>::freebuf (T *buffer) { - delete[] buffer; + delete [] buffer; } // ************************************************************* |