diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 1999-08-02 15:53:59 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 1999-08-02 15:53:59 +0000 |
commit | 141633a05c85b9ee124ad8d41c80bed7fda56a5c (patch) | |
tree | 0ed4816850b44baf99eeae1d9960f144a14d6502 | |
parent | 63fa7925dbb23fc5bccc37655e3e0e9c4de9120a (diff) | |
download | ATCD-141633a05c85b9ee124ad8d41c80bed7fda56a5c.tar.gz |
Use ACE_NEW_RETURN macros instead of basic C++ `new' to allocate
memory.
Moved allocation of connector lock after call to
make_caching_strategy() to prevent a potential memory leak from
occurring.
-rw-r--r-- | TAO/tao/IIOP_Connector.cpp | 40 | ||||
-rw-r--r-- | TAO/tao/UIOP_Connector.cpp | 35 |
2 files changed, 40 insertions, 35 deletions
diff --git a/TAO/tao/IIOP_Connector.cpp b/TAO/tao/IIOP_Connector.cpp index b9c79c413e5..5487f96f0ef 100644 --- a/TAO/tao/IIOP_Connector.cpp +++ b/TAO/tao/IIOP_Connector.cpp @@ -53,24 +53,30 @@ TAO_IIOP_Connector::open (TAO_ORB_Core *orb_core) { this->orb_core_ = orb_core; - TAO_Cached_Connector_Lock *connector_lock = 0; - ACE_NEW_RETURN (connector_lock, - TAO_Cached_Connector_Lock (this->orb_core_), - -1); - int result = this->make_caching_strategy (); if (result == -1) return -1; - // @@ We should use ACE_NEW here - this->cached_connect_strategy_ = - new CACHED_CONNECT_STRATEGY (*this->caching_strategy_, - new TAO_IIOP_Connect_Creation_Strategy (this->orb_core_->thr_mgr (), - this->orb_core_), - 0, - 0, - connector_lock, - 1); + TAO_Cached_Connector_Lock *connector_lock = 0; + ACE_NEW_RETURN (connector_lock, + TAO_Cached_Connector_Lock (this->orb_core_), + -1); + + TAO_IIOP_Connect_Creation_Strategy *connect_creation_strategy = 0; + ACE_NEW_RETURN (connect_creation_strategy, + TAO_IIOP_Connect_Creation_Strategy ( + this->orb_core_->thr_mgr (), + this->orb_core_), + -1); + + ACE_NEW_RETURN (this->cached_connect_strategy_, + CACHED_CONNECT_STRATEGY (*this->caching_strategy_, + connect_creation_strategy, + 0, + 0, + connector_lock, + 1), + -1); return this->base_connector_.open (this->orb_core_->reactor (), &this->null_creation_strategy_, @@ -81,17 +87,13 @@ TAO_IIOP_Connector::open (TAO_ORB_Core *orb_core) int TAO_IIOP_Connector::close (void) { - // - // @@ Can we delete the strategies that the connector uses before we - // close the connector itself?? - // + this->base_connector_.close (); // Zap the creation strategy that we created earlier delete this->cached_connect_strategy_->creation_strategy (); delete this->cached_connect_strategy_; delete this->caching_strategy_; - this->base_connector_.close (); return 0; } diff --git a/TAO/tao/UIOP_Connector.cpp b/TAO/tao/UIOP_Connector.cpp index de9faf63595..44694cf1aad 100644 --- a/TAO/tao/UIOP_Connector.cpp +++ b/TAO/tao/UIOP_Connector.cpp @@ -55,23 +55,30 @@ TAO_UIOP_Connector::open (TAO_ORB_Core *orb_core) { this->orb_core_ = orb_core; + int result = this->make_caching_strategy (); + if (result == -1) + return -1; + TAO_Cached_Connector_Lock *connector_lock = 0; ACE_NEW_RETURN (connector_lock, TAO_Cached_Connector_Lock (orb_core), -1); - int result = this->make_caching_strategy (); - if (result == -1) - return -1; + TAO_UIOP_Connect_Creation_Strategy *connect_creation_strategy = 0; + ACE_NEW_RETURN (connect_creation_strategy, + TAO_UIOP_Connect_Creation_Strategy ( + this->orb_core_->thr_mgr (), + this->orb_core_), + -1); - this->cached_connect_strategy_ = - new CACHED_CONNECT_STRATEGY (*this->caching_strategy_, - new TAO_UIOP_Connect_Creation_Strategy (this->orb_core_->thr_mgr (), - this->orb_core_), - 0, - 0, - connector_lock, - 1); + ACE_NEW_RETURN (this->cached_connect_strategy_, + CACHED_CONNECT_STRATEGY (*this->caching_strategy_, + connect_creation_strategy, + 0, + 0, + connector_lock, + 1), + -1); return this->base_connector_.open (this->orb_core_->reactor (), &this->null_creation_strategy_, @@ -82,17 +89,13 @@ TAO_UIOP_Connector::open (TAO_ORB_Core *orb_core) int TAO_UIOP_Connector::close (void) { - // - // @@ Can we delete the strategies that the connector uses before we - // close the connector itself?? - // + this->base_connector_.close (); // Zap the creation strategy that we created earlier delete this->cached_connect_strategy_->creation_strategy (); delete this->cached_connect_strategy_; delete this->caching_strategy_; - this->base_connector_.close (); return 0; } |