From: eap Date: Thu, 1 Oct 2009 05:43:57 +0000 (+0000) Subject: fix memory leak in testInterpolationCC() X-Git-Tag: V5_1_main_FINAL~325 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7714b8169ff39a22092358f12ff739f2dbecd903;p=tools%2Fmedcoupling.git fix memory leak in testInterpolationCC() --- diff --git a/src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx b/src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx index b8627f689..51b8bc29e 100644 --- a/src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx +++ b/src/MEDCoupling/Test/MEDCouplingBasicsTest.cxx @@ -1464,14 +1464,14 @@ void MEDCouplingBasicsTest::test3DInterpP1P1_1() myInterpolator.setPrecision(1e-12); myInterpolator.interpolateMeshes(sourceWrapper,targetWrapper,res,"P1P1"); CPPUNIT_ASSERT_EQUAL(8,(int)res.size()); - double res3D[8][28]= {{124999.9998734956, 245370.37040407892, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 203703.70363489218, 187500.00010210334, 0.0, 0.0, 4629.6296278851705, 0.0, 215277.77775140284, 209722.22233129849, 0.0, 0.0, 0.0, 0.0, 104166.66659405759, 121296.29636805809, 0.0, 250000.0000034722}, - {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 120370.37036767052, 0.0, 0.0, 38888.888890105758, 0.0, 0.0, 45370.370367507297, 0.0, 0.0, 45370.370372929341, 83333.333326388965, 0.0}, - {0.0, 0.0, 0.0, 97222.222222222161, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 97222.222222222292, 0.0, 97222.222222428492, 41666.666666666664, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - {0.0, 277777.77779597207, 199074.07407081372, 0.0, 0.0, 0.0, 4629.6296296296196, 0.0, 321759.25925580953, 83333.333333333256, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4629.6296276787943, 0.0, 0.0, 251388.88888547334, 194444.44445378651, 0.0, 79629.62962210011, 250000.00000347217, 0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0, 85185.185185185197, 4629.6296296296277, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.51851851863, 0.0, 41666.666666666657, 83333.333333333343, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - {0.0, 324074.07409050438, 0.0, 0.0, 0.0, 247685.18518518523, 6481.4814814814881, 0.0, 173611.11111694883, 0.0, 164814.81481481477, 0.0, 4629.6296296296259, 208333.33333273651, 0.0, 83333.333333333328, 203703.7037000655, 250000.00000000003, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - {124999.99999702119, 423611.11112090992, 134259.2592592593, 194444.4444444445, 164814.81481481463, 164351.85185185185, 203703.70370370374, 250000.00000000009, 0.0, 0.0, 0.0, 0.0, 6481.4814814814981, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, - {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.51851851857, 0.0, 4629.6296296296377, 83333.333333333343, 85185.185185185226, 41666.666666666657, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; + double res3D[8][28]= {{124999.999883775978, 245370.370390364464, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 203703.703634892299, 187500.000094145857, 0.0, 0.0, 4629.6296266718, 0.0, 215277.777751402784, 209722.222322299582, 0.0, 0.0, 0.0, 0.0, 104166.666590829205, 121296.296368812196, 0.0, 250000.000003472145}, + {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 120370.370368827047, 0.0, 0.0, 38888.888897777797, 0.0, 0.0, 45370.3703701697596, 0.0, 0.0, 45370.3703701697596, 83333.3333263888926, 0.0}, + {0.0, 0.0, 0.0, 97222.2222222221753, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 97222.2222222221608, 0.0, 97222.2222222222044, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + {0.0, 277777.777787084982, 199074.074074073927, 0.0, 0.0, 0.0, 4629.62962962962774, 0.0, 321759.259254934732, 83333.3333333333139, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 4629.62962667180363, 0.0, 0.0, 251388.88888319055, 194444.444454861077, 0.0, 79629.6296194135939, 250000.000003472145, 0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0, 85185.1851851851534, 4629.62962962962774, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.518518518511, 0.0, 41666.6666666666642, 83333.3333333333285, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + {0.0, 324074.07407629228, 0.0, 0.0, 0.0, 247685.185185184964, 6481.48148148147993, 0.0, 173611.11111196311, 0.0, 164814.814814814832, 0.0, 4629.62962962962865, 208333.33333418527, 0.0, 83333.3333333333285, 203703.703697273799, 249999.999999999767, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + {125000.000000000015, 423611.111111110775, 134259.259259259241, 194444.444444444351, 164814.814814814745, 164351.851851851825, 203703.703703703592, 249999.999999999825, 0.0, 0.0, 0.0, 0.0, 6481.48148148147902, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}, + {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 118518.518518518453, 0.0, 4629.62962962962956, 83333.3333333333139, 85185.1851851851825, 41666.6666666666642, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}}; int i=0; double sum = 0; //cout.precision(18); @@ -1485,7 +1485,7 @@ void MEDCouplingBasicsTest::test3DInterpP1P1_1() { //cout<< iter2->second<< ", "; sum += iter2->second; - CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-3); + CPPUNIT_ASSERT_DOUBLES_EQUAL(res3D[i][j],(*iter2).second,1.e-5); } else { @@ -1534,18 +1534,19 @@ void MEDCouplingBasicsTest::test3DInterpP0P0Empty() void MEDCouplingBasicsTest::testInterpolationCC() { + double arr1[3] = { 0/2., 1/2., 2/2. }; + double arr2[4] = { 0/3, 1/3., 2/3., 3/3. }; MEDCouplingCMesh* mesh[2]; for ( int i = 0; i < 2; ++i ) { - double arr1[3] = { 0/2., 1/2., 2/2. }; - double arr2[4] = { 0/3, 1/3., 2/3., 3/3. }; const double* arr = i ? arr1 : arr2; const int nb_coord = i ? 3 : 4; DataArrayDouble* coords = DataArrayDouble::New(); - coords->useArray( arr, /*ownership=*/true, CPP_DEALLOC, nb_coord, 1 ); + coords->useArray( arr, /*ownership=*/false, CPP_DEALLOC, nb_coord, 1 ); mesh[i] = MEDCouplingCMesh::New(); mesh[i]->setCoords( coords, coords, coords ); + coords->decrRef(); } MEDCouplingNormalizedCartesianMesh<3,3> targetWrapper(mesh[1]); MEDCouplingNormalizedCartesianMesh<3,3> sourceWrapper(mesh[0]);