Ignore:
Timestamp:
12/01/21 16:52:24 (3 years ago)
Author:
ymipsl
Message:

tracking memory leak
Elements, views, and connectors are now managed with shared pointer.
YM

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XIOS/dev/dev_ym/XIOS_COUPLING/src/distribution/element.cpp

    r1930 r2267  
    2828  void CDistributedElement::addView(CElementView::type type, std::map<int, CArray<int,1>>& indexView) 
    2929  { 
    30     views_[type] = new CDistributedView(this, type, indexView) ; 
     30    views_[type] = make_shared<CDistributedView>(shared_from_this(), type, indexView) ; 
    3131  }  
    3232 
    3333  void CDistributedElement::addView(CElementView::type type, std::map<int, CArray<bool,1>>& maskView) 
    3434  { 
    35     views_[type] = new CDistributedView(this, type, maskView) ; 
     35    views_[type] = make_shared<CDistributedView>(shared_from_this(), type, maskView) ; 
    3636  }  
    3737 
     
    120120  void CLocalElement::addView(CElementView::type type, CArray<int,1>& indexView) 
    121121  { 
    122     views_[type] = new CLocalView(this, type, indexView) ; 
     122    views_[type] = make_shared<CLocalView>(static_pointer_cast<CLocalElement>(shared_from_this()), type, indexView) ; 
    123123  }  
    124124 
    125125  void CLocalElement::addView(CElementView::type type, CArray<bool,1>& maskView) 
    126126  { 
    127     views_[type] = new CLocalView(this, type, maskView) ; 
     127    views_[type] = make_shared<CLocalView>(static_pointer_cast<CLocalElement>(shared_from_this()), type, maskView) ; 
    128128  }  
    129129 
     
    137137  }  
    138138 
    139   CLocalConnector* CLocalElement::getConnector(CElementView::type srcType, CElementView::type dstType)  
     139  shared_ptr<CLocalView> CLocalElement::getView(CElementView::type type)  
     140  {  
     141    if (views_[(size_t)type]==nullptr) { ERROR("CLocalElement::getView(CElementView::type type)",<<"View is not initialized");}  
     142    else return static_pointer_cast<CLocalView>(views_[(size_t)type]) ; 
     143  } 
     144 
     145  shared_ptr<CLocalConnector> CLocalElement::getConnector(CElementView::type srcType, CElementView::type dstType)  
    140146  {  
    141147    auto newPair = pair<CElementView::type,CElementView::type>(srcType,dstType); 
     
    143149    if (it==connectors_.end())  
    144150    { 
    145       auto insertPair=pair<pair<CElementView::type,CElementView::type>, CLocalConnector*>(newPair,new CLocalConnector(getView(srcType),getView(dstType))) ; 
     151      auto insertPair=pair<pair<CElementView::type,CElementView::type>, shared_ptr<CLocalConnector>>(newPair,make_shared<CLocalConnector>(getView(srcType),getView(dstType))) ; 
    146152      it=connectors_.insert(insertPair).first ; 
    147153      it->second->computeConnector() ; 
Note: See TracChangeset for help on using the changeset viewer.