summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfredk <fredk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-02-06 00:14:37 +0000
committerfredk <fredk@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-02-06 00:14:37 +0000
commit8674156cda1bc8079b965081aea111ecbf02d3e8 (patch)
treed5630de8acb65962ea82ae63af8a8d87887d4ff2
parent3e82a0c77ed9f3d1ba4d8778db7b0f833fbf6b7f (diff)
downloadATCD-8674156cda1bc8079b965081aea111ecbf02d3e8.tar.gz
*** empty log message ***
-rw-r--r--TAO/ChangeLog-99c4
-rw-r--r--TAO/tao/MProfile.cpp81
2 files changed, 54 insertions, 31 deletions
diff --git a/TAO/ChangeLog-99c b/TAO/ChangeLog-99c
index 724720b833b..8f03ae72028 100644
--- a/TAO/ChangeLog-99c
+++ b/TAO/ChangeLog-99c
@@ -1,3 +1,7 @@
+Fri Feb 5 18:11:33 1999 Fred Kuhns <fredk@cs.wustl.edu>
+ * tao/MProfile.cpp
+ Fixed set () so it would reinitialize the list of profiles.
+
Fri Feb 05 16:55:00 1999 Chris Gill <cdgill@cs.wustl.edu>
* TAO/orbsvcs/tests/Simulator/README: Documented DualEC_Sup.
diff --git a/TAO/tao/MProfile.cpp b/TAO/tao/MProfile.cpp
index 96588cced1e..ac922cb2948 100644
--- a/TAO/tao/MProfile.cpp
+++ b/TAO/tao/MProfile.cpp
@@ -27,10 +27,9 @@ TAO_MProfile::TAO_MProfile (TAO_MProfile *mprofiles)
int
TAO_MProfile::set (CORBA::ULong sz)
{
- // first release all of our profiles.
- if (this->pfiles_)
+ if (sz == 0)
{
-
+ // We do, so release all of our profiles.
for (PHandle h = 0; h < this->size_; h++ )
{
if (this->pfiles_[h])
@@ -39,48 +38,68 @@ TAO_MProfile::set (CORBA::ULong sz)
this->pfiles_[h] = 0;
}
}
+
+ if (size_)
+ delete [] this->pfiles_;
+
+ if (fwded_mprofile_)
+ delete fwded_mprofile_;
+
+ pfiles_ = 0;
+ current_ = 0;
+ size_ = 0;
+ last_= 0;
+
+ return 0;
+ }
+
+ // see if we already have an existing profile list
+ // or if we need to get ridof what we have
+ if (size_)
+ {
+
+ // We do, so release all of our profiles.
+ for (PHandle h = 0; h < size_; h++)
+ {
+ if (this->pfiles_[h])
+ {
+ this->pfiles_[h]->_decr_refcnt ();
+ this->pfiles_[h] = 0;
+ }
+ }
// Next see if we can reuse our profile list memory Since
- // this->pfiles_ != 0, size_ > 0! So if sz == 0 then memory is
- // deallocated.
if (this->size_ != sz)
{
- // we cant!
+ // we cant reuse memory since the array sized are different!
delete [] this->pfiles_;
- if (this->size_ == sz)
- {
- ACE_NEW_RETURN (this->pfiles_,
- TAO_Profile_ptr [this->size_],
- -1);
- ACE_OS::memset (this->pfiles_,
- 0,
- sizeof (TAO_Profile_ptr) *this->size_);
- }
- else // do not allocate any memory!
- this->pfiles_ = 0;
- }
+ ACE_NEW_RETURN (this->pfiles_,
+ TAO_Profile_ptr [sz],
+ -1);
+ }
}
else
{
- if (this->size_ == sz)
- {
- ACE_NEW_RETURN (this->pfiles_,
- TAO_Profile_ptr [this->size_],
- -1);
- ACE_OS::memset (this->pfiles_,
- 0,
- sizeof (TAO_Profile_ptr) *this->size_);
- }
- else
- pfiles_ = 0;
+ // first time, initialize!
+ ACE_NEW_RETURN (this->pfiles_,
+ TAO_Profile_ptr [sz],
+ -1);
} // this->pfiles_
+ ACE_OS::memset (this->pfiles_,
+ 0,
+ sizeof (TAO_Profile_ptr) * sz);
+
+ size_ = sz;
this->last_ = 0;
this->current_ = 0;
- this->fwded_mprofile_ = 0;
- return 1;
+ // @@ since we are being reset, get rid of fwd references!
+ if (fwded_mprofile_)
+ delete fwded_mprofile_;
+
+ return size_;
}
int