From: ageay Date: Tue, 26 Feb 2013 11:10:08 +0000 (+0000) Subject: cleanup decrRef X-Git-Tag: V6_main_FINAL~335 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=34387ecef9257fd02dd734b4fb16f315f9aeb7dc;p=tools%2Fmedcoupling.git cleanup decrRef --- diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index a34d71b80..52e9fe964 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -1989,7 +1989,7 @@ MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const DataArrayInt *revDesc=DataArrayInt::New(); DataArrayInt *revDescIndx=DataArrayInt::New(); // - MEDCouplingUMesh *meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); + MEDCouplingAutoRefCountObjectPtr meshDM1=buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); revDesc->decrRef(); desc->decrRef(); descIndx->decrRef(); @@ -2001,7 +2001,6 @@ MEDCouplingPointSet *MEDCouplingUMesh::buildBoundaryMesh(bool keepCoords) const boundaryCells.push_back(i); revDescIndx->decrRef(); MEDCouplingPointSet *ret=meshDM1->buildPartOfMySelf(&boundaryCells[0],&boundaryCells[0]+boundaryCells.size(),keepCoords); - meshDM1->decrRef(); return ret; } @@ -2906,15 +2905,13 @@ void MEDCouplingUMesh::unserialization(const std::vector& tinyInfoD, con { // Connectivity const int *recvBuffer=a1->getConstPointer(); - DataArrayInt* myConnecIndex=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr myConnecIndex=DataArrayInt::New(); myConnecIndex->alloc(tinyInfo[6]+1,1); std::copy(recvBuffer,recvBuffer+tinyInfo[6]+1,myConnecIndex->getPointer()); - DataArrayInt* myConnec=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr myConnec=DataArrayInt::New(); myConnec->alloc(tinyInfo[7],1); std::copy(recvBuffer+tinyInfo[6]+1,recvBuffer+tinyInfo[6]+1+tinyInfo[7],myConnec->getPointer()); - setConnectivity(myConnec, myConnecIndex) ; - myConnec->decrRef(); - myConnecIndex->decrRef(); + setConnectivity(myConnec, myConnecIndex); } } @@ -2999,14 +2996,12 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildPartOfMySelfKeepCoords(const int *begin types.insert((INTERP_KERNEL::NormalizedCellType)conn[connIndex[*work]]); connRetWork=std::copy(conn+connIndex[*work],conn+connIndex[*work+1],connRetWork); } - DataArrayInt *connRetArr=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr connRetArr=DataArrayInt::New(); connRetArr->useArray(connRet,true,CPP_DEALLOC,connIndexRet[nbOfElemsRet],1); - DataArrayInt *connIndexRetArr=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr connIndexRetArr=DataArrayInt::New(); connIndexRetArr->useArray(connIndexRet,true,CPP_DEALLOC,(int)nbOfElemsRet+1,1); ret->setConnectivity(connRetArr,connIndexRetArr,false); ret->_types=types; - connRetArr->decrRef(); - connIndexRetArr->decrRef(); ret->copyTinyInfoFrom(this); return ret.retn(); } @@ -3025,13 +3020,12 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const std::string name="MeasureOfMesh_"; name+=getName(); int nbelem=getNumberOfCells(); - MEDCouplingFieldDouble *field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + MEDCouplingAutoRefCountObjectPtr field=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); field->setName(name.c_str()); - DataArrayDouble* array=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr array=DataArrayDouble::New(); array->alloc(nbelem,1); double *area_vol=array->getPointer(); - field->setArray(array) ; - array->decrRef(); + field->setArray(array) ; array=0; field->setMesh(const_cast(this)); field->synchronizeTimeWithMesh(); if(getMeshDimension()!=-1) @@ -3055,7 +3049,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureField(bool isAbs) const { area_vol[0]=std::numeric_limits::max(); } - return field; + return field.retn(); } /*! @@ -3067,7 +3061,7 @@ DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const int *be std::string name="PartMeasureOfMesh_"; name+=getName(); int nbelem=(int)std::distance(begin,end); - DataArrayDouble* array=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr array=DataArrayDouble::New(); array->setName(name.c_str()); array->alloc(nbelem,1); double *area_vol=array->getPointer(); @@ -3092,7 +3086,7 @@ DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const int *be { area_vol[0]=std::numeric_limits::max(); } - return array; + return array.retn(); } /*! @@ -3101,19 +3095,19 @@ DataArrayDouble *MEDCouplingUMesh::getPartMeasureField(bool isAbs, const int *be */ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) const { - MEDCouplingFieldDouble *tmp=getMeasureField(isAbs); + MEDCouplingAutoRefCountObjectPtr tmp=getMeasureField(isAbs); std::string name="MeasureOnNodeOfMesh_"; name+=getName(); int nbNodes=getNumberOfNodes(); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_NODES); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_NODES); double cst=1./((double)getMeshDimension()+1.); - DataArrayDouble* array=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr array=DataArrayDouble::New(); array->alloc(nbNodes,1); double *valsToFill=array->getPointer(); std::fill(valsToFill,valsToFill+nbNodes,0.); const double *values=tmp->getArray()->getConstPointer(); - DataArrayInt *da=DataArrayInt::New(); - DataArrayInt *daInd=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr da=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr daInd=DataArrayInt::New(); getReverseNodalConnectivity(da,daInd); const int *daPtr=da->getConstPointer(); const int *daIPtr=daInd->getConstPointer(); @@ -3121,12 +3115,8 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getMeasureFieldOnNode(bool isAbs) cons for(const int *cell=daPtr+daIPtr[i];cell!=daPtr+daIPtr[i+1];cell++) valsToFill[i]+=cst*values[*cell]; ret->setMesh(this); - da->decrRef(); - daInd->decrRef(); ret->setArray(array); - array->decrRef(); - tmp->decrRef(); - return ret; + return ret.retn(); } /*! @@ -3137,8 +3127,8 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const { if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2)) throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - DataArrayDouble *array=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + MEDCouplingAutoRefCountObjectPtr array=DataArrayDouble::New(); int nbOfCells=getNumberOfCells(); int nbComp=getMeshDimension()+1; array->alloc(nbOfCells,nbComp); @@ -3150,7 +3140,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const { if(getSpaceDimension()==3) { - DataArrayDouble *loc=getBarycenterAndOwner(); + MEDCouplingAutoRefCountObjectPtr loc=getBarycenterAndOwner(); const double *locPtr=loc->getConstPointer(); for(int i=0;i(vals); std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies(),1./n)); } - loc->decrRef(); } else { @@ -3181,10 +3170,9 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildOrthogonalField() const } } ret->setArray(array); - array->decrRef(); ret->setMesh(this); ret->synchronizeTimeWithSupport(); - return ret; + return ret.retn(); } /*! @@ -3195,8 +3183,8 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *be { if((getMeshDimension()!=2) && (getMeshDimension()!=1 || getSpaceDimension()!=2)) throw INTERP_KERNEL::Exception("Expected a umesh with ( meshDim == 2 spaceDim == 2 or 3 ) or ( meshDim == 1 spaceDim == 2 ) !"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - DataArrayDouble *array=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + MEDCouplingAutoRefCountObjectPtr array=DataArrayDouble::New(); std::size_t nbelems=std::distance(begin,end); int nbComp=getMeshDimension()+1; array->alloc((int)nbelems,nbComp); @@ -3208,7 +3196,7 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *be { if(getSpaceDimension()==3) { - DataArrayDouble *loc=getPartBarycenterAndOwner(begin,end); + MEDCouplingAutoRefCountObjectPtr loc=getPartBarycenterAndOwner(begin,end); const double *locPtr=loc->getConstPointer(); for(const int *i=begin;i!=end;i++,vals+=3,locPtr+=3) { @@ -3217,7 +3205,6 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *be double n=INTERP_KERNEL::norm<3>(vals); std::transform(vals,vals+3,vals,std::bind2nd(std::multiplies(),1./n)); } - loc->decrRef(); } else { @@ -3239,10 +3226,9 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildPartOrthogonalField(const int *be } } ret->setArray(array); - array->decrRef(); ret->setMesh(this); ret->synchronizeTimeWithSupport(); - return ret; + return ret.retn(); } /*! @@ -3255,8 +3241,8 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const throw INTERP_KERNEL::Exception("Expected a umesh with meshDim == 1 for buildDirectionVectorField !"); if(_types.size()!=1 || *(_types.begin())!=INTERP_KERNEL::NORM_SEG2) throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for buildDirectionVectorField !"); - MEDCouplingFieldDouble *ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); - DataArrayDouble *array=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); + MEDCouplingAutoRefCountObjectPtr array=DataArrayDouble::New(); int nbOfCells=getNumberOfCells(); int spaceDim=getSpaceDimension(); array->alloc(nbOfCells,spaceDim); @@ -3271,10 +3257,9 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::buildDirectionVectorField() const pt=std::transform(coo+conn[1]*spaceDim,coo+(conn[1]+1)*spaceDim,coo+conn[0]*spaceDim,pt,std::minus()); } ret->setArray(array); - array->decrRef(); ret->setMesh(this); ret->synchronizeTimeWithSupport(); - return ret; + return ret.retn(); } /*! @@ -3494,7 +3479,7 @@ void MEDCouplingUMesh::project1D(const double *pt, const double *v, double eps, throw INTERP_KERNEL::Exception("Expected a umesh with only NORM_SEG2 type of elements for project1D !"); if(getSpaceDimension()!=3) throw INTERP_KERNEL::Exception("Expected a umesh with spaceDim==3 for project1D !"); - MEDCouplingFieldDouble *f=buildDirectionVectorField(); + MEDCouplingAutoRefCountObjectPtr f=buildDirectionVectorField(); const double *fPtr=f->getArray()->getConstPointer(); double tmp[3]; for(int i=0;i(tmp); n1/=INTERP_KERNEL::norm<3>(tmp1); if(n1>eps) - { - f->decrRef(); - throw INTERP_KERNEL::Exception("UMesh::Projection 1D failed !"); - } + throw INTERP_KERNEL::Exception("UMesh::Projection 1D failed !"); } const double *coo=getCoords()->getConstPointer(); for(int i=0;i()); res[i]=std::accumulate(tmp,tmp+3,0.); } - f->decrRef(); } /*! @@ -3997,7 +3978,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *me } zipCoords(); int oldNbOfNodes=getNumberOfNodes(); - DataArrayDouble *newCoords=0; + MEDCouplingAutoRefCountObjectPtr newCoords; switch(policy) { case 0: @@ -4014,10 +3995,9 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMesh(const MEDCouplingUMesh *me throw INTERP_KERNEL::Exception("Not implemented extrusion policy : must be in (0) !"); } setCoords(newCoords); - newCoords->decrRef(); - MEDCouplingUMesh *ret=buildExtrudedMeshFromThisLowLev(oldNbOfNodes,isQuad); + MEDCouplingAutoRefCountObjectPtr ret=buildExtrudedMeshFromThisLowLev(oldNbOfNodes,isQuad); updateTime(); - return ret; + return ret.retn(); } /*! @@ -4160,15 +4140,14 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(con int nbOf1DCells=mesh1D->getNumberOfCells(); if(nbOf1DCells<2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !"); - DataArrayDouble *ret=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayDouble::New(); int nbOfLevsInVec=nbOf1DCells+1; ret->alloc(oldNbOfNodes*nbOfLevsInVec,2); double *retPtr=ret->getPointer(); retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr); - MEDCouplingUMesh *tmp=MEDCouplingUMesh::New(); - DataArrayDouble *tmp2=getCoords()->deepCpy(); + MEDCouplingAutoRefCountObjectPtr tmp=MEDCouplingUMesh::New(); + MEDCouplingAutoRefCountObjectPtr tmp2=getCoords()->deepCpy(); tmp->setCoords(tmp2); - tmp2->decrRef(); const double *coo1D=mesh1D->getCoords()->getConstPointer(); const int *conn1D=mesh1D->getNodalConnectivity()->getConstPointer(); const int *connI1D=mesh1D->getNodalConnectivityIndex()->getConstPointer(); @@ -4189,8 +4168,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation2D(con tmp->rotate(end,0,angle); retPtr=std::copy(tmp2->getConstPointer(),tmp2->getConstPointer()+tmp2->getNbOfElems(),retPtr); } - tmp->decrRef(); - return ret; + return ret.retn(); } /*! @@ -4206,15 +4184,14 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(con int nbOf1DCells=mesh1D->getNumberOfCells(); if(nbOf1DCells<2) throw INTERP_KERNEL::Exception("MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D : impossible to detect any angle of rotation ! Change extrusion policy 1->0 !"); - DataArrayDouble *ret=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr ret=DataArrayDouble::New(); int nbOfLevsInVec=nbOf1DCells+1; ret->alloc(oldNbOfNodes*nbOfLevsInVec,3); double *retPtr=ret->getPointer(); retPtr=std::copy(getCoords()->getConstPointer(),getCoords()->getConstPointer()+getCoords()->getNbOfElems(),retPtr); - MEDCouplingUMesh *tmp=MEDCouplingUMesh::New(); - DataArrayDouble *tmp2=getCoords()->deepCpy(); + MEDCouplingAutoRefCountObjectPtr tmp=MEDCouplingUMesh::New(); + MEDCouplingAutoRefCountObjectPtr tmp2=getCoords()->deepCpy(); tmp->setCoords(tmp2); - tmp2->decrRef(); const double *coo1D=mesh1D->getCoords()->getConstPointer(); const int *conn1D=mesh1D->getNodalConnectivity()->getConstPointer(); const int *connI1D=mesh1D->getNodalConnectivityIndex()->getConstPointer(); @@ -4258,8 +4235,7 @@ DataArrayDouble *MEDCouplingUMesh::fillExtCoordsUsingTranslAndAutoRotation3D(con } retPtr=std::copy(tmp2->getConstPointer(),tmp2->getConstPointer()+tmp2->getNbOfElems(),retPtr); } - tmp->decrRef(); - return ret; + return ret.retn(); } /*! @@ -4276,8 +4252,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThisLowLev(int nbOfNode MEDCouplingUMesh *ret=MEDCouplingUMesh::New("Extruded",getMeshDimension()+1); const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); - DataArrayInt *newConn=DataArrayInt::New(); - DataArrayInt *newConnI=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr newConn=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr newConnI=DataArrayInt::New(); newConnI->alloc(nbOf3DCells+1,1); int *newConnIPtr=newConnI->getPointer(); *newConnIPtr++=0; @@ -4310,8 +4286,6 @@ MEDCouplingUMesh *MEDCouplingUMesh::buildExtrudedMeshFromThisLowLev(int nbOfNode } } ret->setConnectivity(newConn,newConnI,true); - newConn->decrRef(); - newConnI->decrRef(); ret->setCoords(getCoords()); return ret; } @@ -5150,11 +5124,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getEdgeRatioField() const throw(INTERP MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); ret->setMesh(this); int nbOfCells=getNumberOfCells(); - DataArrayDouble *arr=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr arr=DataArrayDouble::New(); arr->alloc(nbOfCells,1); double *pt=arr->getPointer(); ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - arr->decrRef(); const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); const double *coo=_coords->getConstPointer(); @@ -5210,11 +5183,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getAspectRatioField() const throw(INTE MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); ret->setMesh(this); int nbOfCells=getNumberOfCells(); - DataArrayDouble *arr=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr arr=DataArrayDouble::New(); arr->alloc(nbOfCells,1); double *pt=arr->getPointer(); ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - arr->decrRef(); const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); const double *coo=_coords->getConstPointer(); @@ -5270,11 +5242,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getWarpField() const throw(INTERP_KERN MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); ret->setMesh(this); int nbOfCells=getNumberOfCells(); - DataArrayDouble *arr=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr arr=DataArrayDouble::New(); arr->alloc(nbOfCells,1); double *pt=arr->getPointer(); ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - arr->decrRef(); const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); const double *coo=_coords->getConstPointer(); @@ -5318,11 +5289,10 @@ MEDCouplingFieldDouble *MEDCouplingUMesh::getSkewField() const throw(INTERP_KERN MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingFieldDouble::New(ON_CELLS,ONE_TIME); ret->setMesh(this); int nbOfCells=getNumberOfCells(); - DataArrayDouble *arr=DataArrayDouble::New(); + MEDCouplingAutoRefCountObjectPtr arr=DataArrayDouble::New(); arr->alloc(nbOfCells,1); double *pt=arr->getPointer(); ret->setArray(arr);//In case of throw to avoid mem leaks arr will be used after decrRef. - arr->decrRef(); const int *conn=_nodal_connec->getConstPointer(); const int *connI=_nodal_connec_index->getConstPointer(); const double *coo=_coords->getConstPointer(); @@ -6166,14 +6136,13 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(std::vector aps(a.size()); std::copy(a.begin(),a.end(),aps.begin()); - DataArrayDouble *pts=MergeNodesArray(aps); + MEDCouplingAutoRefCountObjectPtr pts=MergeNodesArray(aps); MEDCouplingAutoRefCountObjectPtr ret=MEDCouplingUMesh::New("merge",meshDim); ret->setCoords(pts); - pts->decrRef(); - DataArrayInt *c=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr c=DataArrayInt::New(); c->alloc(meshLgth,1); int *cPtr=c->getPointer(); - DataArrayInt *cI=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr cI=DataArrayInt::New(); cI->alloc(nbOfCells+1,1); int *cIPtr=cI->getPointer(); *cIPtr++=0; @@ -6202,8 +6171,6 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesLL(std::vectorsetConnectivity(c,cI,true); - c->decrRef(); - cI->decrRef(); return ret.retn(); } @@ -6248,10 +6215,10 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vectorgetMeshLength(); meshIndexLgth+=(*iter)->getNumberOfCells(); } - DataArrayInt *nodal=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr nodal=DataArrayInt::New(); nodal->alloc(meshLgth,1); int *nodalPtr=nodal->getPointer(); - DataArrayInt *nodalIndex=DataArrayInt::New(); + MEDCouplingAutoRefCountObjectPtr nodalIndex=DataArrayInt::New(); nodalIndex->alloc(meshIndexLgth+1,1); int *nodalIndexPtr=nodalIndex->getPointer(); int offset=0; @@ -6273,8 +6240,6 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vectorsetMeshDimension(meshDim); ret->setConnectivity(nodal,nodalIndex,true); ret->setCoords(coords); - nodalIndex->decrRef(); - nodal->decrRef(); return ret; } @@ -6293,8 +6258,8 @@ MEDCouplingUMesh *MEDCouplingUMesh::MergeUMeshesOnSameCoords(const std::vector& meshes, int compType, std::vector& corr) { //All checks are delegated to MergeUMeshesOnSameCoords - MEDCouplingUMesh *ret=MergeUMeshesOnSameCoords(meshes); - DataArrayInt *o2n=ret->zipConnectivityTraducer(compType); + MEDCouplingAutoRefCountObjectPtr ret=MergeUMeshesOnSameCoords(meshes); + MEDCouplingAutoRefCountObjectPtr o2n=ret->zipConnectivityTraducer(compType); corr.resize(meshes.size()); std::size_t nbOfMeshes=meshes.size(); int offset=0; @@ -6309,8 +6274,7 @@ MEDCouplingUMesh *MEDCouplingUMesh::FuseUMeshesOnSameCoords(const std::vectorsetName(meshes[i]->getName()); corr[i]=tmp; } - o2n->decrRef(); - return ret; + return ret.retn(); } /*!