diff --git a/Cassiopee/Converter/Converter/convertStruct2NGon.cpp b/Cassiopee/Converter/Converter/convertStruct2NGon.cpp index f25f03cbd..d7549ee6a 100644 --- a/Cassiopee/Converter/Converter/convertStruct2NGon.cpp +++ b/Cassiopee/Converter/Converter/convertStruct2NGon.cpp @@ -386,10 +386,14 @@ PyObject* K_CONVERTER::convertStruct2NGon(PyObject* self, PyObject* args) E_Bool rmOverlappingPts=true; E_Bool rmOrphanPts=false; E_Bool rmDuplicatedFaces=true; E_Bool rmDuplicatedElts=false; E_Bool rmDegeneratedFaces=true; E_Bool rmDegeneratedElts=false; - tpl = K_CONNECT::V_cleanConnectivity(varString, *f2, *cn2, "NGON", tol, - rmOverlappingPts, rmOrphanPts, - rmDuplicatedFaces, rmDuplicatedElts, - rmDegeneratedFaces, rmDegeneratedElts); - delete f2; delete cn2; - return tpl; -} \ No newline at end of file + PyObject* tplClean = K_CONNECT::V_cleanConnectivity( + varString, *f2, *cn2, "NGON", tol, + rmOverlappingPts, rmOrphanPts, + rmDuplicatedFaces, rmDuplicatedElts, + rmDegeneratedFaces, rmDegeneratedElts + ); + + RELEASESHAREDU(tpl, f2, cn2); + if (tplClean == NULL) return tpl; + else { Py_DECREF(tpl); return tplClean; } +} diff --git a/Cassiopee/Converter/Converter/convertUnstruct2NGon.cpp b/Cassiopee/Converter/Converter/convertUnstruct2NGon.cpp index a398fc160..0e81b6f42 100644 --- a/Cassiopee/Converter/Converter/convertUnstruct2NGon.cpp +++ b/Cassiopee/Converter/Converter/convertUnstruct2NGon.cpp @@ -381,10 +381,14 @@ PyObject* K_CONVERTER::convertUnstruct2NGon(PyObject* self, PyObject* args) E_Bool rmOverlappingPts=true; E_Bool rmOrphanPts=false; E_Bool rmDuplicatedFaces=true; E_Bool rmDuplicatedElts=false; E_Bool rmDegeneratedFaces=false; E_Bool rmDegeneratedElts=false; - tpl = K_CONNECT::V_cleanConnectivity(varString, *f2, *cn2, "NGON", tol, - rmOverlappingPts, rmOrphanPts, - rmDuplicatedFaces, rmDuplicatedElts, - rmDegeneratedFaces, rmDegeneratedElts); - delete f2; delete cn2; - return tpl; -} \ No newline at end of file + PyObject* tplClean = K_CONNECT::V_cleanConnectivity( + varString, *f2, *cn2, "NGON", tol, + rmOverlappingPts, rmOrphanPts, + rmDuplicatedFaces, rmDuplicatedElts, + rmDegeneratedFaces, rmDegeneratedElts + ); + + RELEASESHAREDU(tpl, f2, cn2); + if (tplClean == NULL) return tpl; + else { Py_DECREF(tpl); return tplClean; } +} diff --git a/Cassiopee/Generator/Generator/close.cpp b/Cassiopee/Generator/Generator/close.cpp index 76febf101..761526726 100644 --- a/Cassiopee/Generator/Generator/close.cpp +++ b/Cassiopee/Generator/Generator/close.cpp @@ -57,7 +57,7 @@ PyObject* K_GENERATOR::closeMesh(PyObject* self, PyObject* args) E_Int posz = K_ARRAY::isCoordinateZPresent(varString); if (posx == -1 || posy == -1 || posz == -1) { - delete f; + RELEASESHAREDB(res, array, f, cn); PyErr_SetString(PyExc_TypeError, "close: can't find coordinates in array."); return NULL; @@ -68,14 +68,14 @@ PyObject* K_GENERATOR::closeMesh(PyObject* self, PyObject* args) { closeStructuredMesh(f->begin(posx), f->begin(posy), f->begin(posz), im, jm, km, eps); PyObject* tpl = K_ARRAY::buildArray3(*f, varString, im, jm, km); - delete f; + RELEASESHAREDS(array, f); return tpl; } else if (res == 2) { if (strchr(eltType, '*') != NULL) { - delete f; delete cn; + RELEASESHAREDU(array, f, cn); PyErr_SetString(PyExc_TypeError, "close: array must be defined at vertices."); return NULL; @@ -85,10 +85,10 @@ PyObject* K_GENERATOR::closeMesh(PyObject* self, PyObject* args) varString, *f, *cn, eltType, eps, rmOverlappingPts, rmOrphanPts, rmDuplicatedFaces, rmDuplicatedElts, rmDegeneratedFaces, rmDegeneratedElts); - if (tpl == NULL) tpl = K_ARRAY::buildArray3(*f, varString, *cn, eltType); // tpl = array; - delete f; delete cn; - return tpl; + RELEASESHAREDU(array, f, cn); + if (tpl == NULL) return array; + else return tpl; } else { diff --git a/Cassiopee/Post/Post/selectExteriorFaces.cpp b/Cassiopee/Post/Post/selectExteriorFaces.cpp index abb18fbad..4a1c91f39 100644 --- a/Cassiopee/Post/Post/selectExteriorFaces.cpp +++ b/Cassiopee/Post/Post/selectExteriorFaces.cpp @@ -837,9 +837,9 @@ PyObject* K_POST::selectExteriorFacesNGon3D(char* varString, FldArrayF& f, { e1 = cFE1[i]; // element voisin 1 e2 = cFE2[i]; // element voisin 2 - E_Int* face = cn.getFace(i, nbnodes, ngon, indPG); if ((e1 == 0 && e2 != 0) || (e2 == 0 && e1 != 0)) { + E_Int* face = cn.getFace(i, nbnodes, ngon, indPG); sizeEF2 += nbnodes+shift; nfacesExt++; exteriorFaces.push_back(i+1);