[cig-commits] r18515 - in short/3D/PyLith/trunk: libsrc/pylith/meshio unittests/libtests/meshio

brad at geodynamics.org brad at geodynamics.org
Tue May 31 18:39:41 PDT 2011


Author: brad
Date: 2011-05-31 18:39:41 -0700 (Tue, 31 May 2011)
New Revision: 18515

Modified:
   short/3D/PyLith/trunk/libsrc/pylith/meshio/ExodusII.cc
   short/3D/PyLith/trunk/libsrc/pylith/meshio/Xdmf.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5.cc
   short/3D/PyLith/trunk/unittests/libtests/meshio/TestHDF5.cc
Log:
Fixed some Xdmf/HDF5 memory leaks.

Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/ExodusII.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/ExodusII.cc	2011-06-01 00:54:13 UTC (rev 18514)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/ExodusII.cc	2011-06-01 01:39:41 UTC (rev 18515)
@@ -133,8 +133,10 @@
     assert(att);
     if (0 == strcmp(att->name(), name)) {
       found = true;
+      delete att; att = 0;
       break;
     } // if
+    delete att; att = 0;
   } // for
   
   return found;

Modified: short/3D/PyLith/trunk/libsrc/pylith/meshio/Xdmf.cc
===================================================================
--- short/3D/PyLith/trunk/libsrc/pylith/meshio/Xdmf.cc	2011-06-01 00:54:13 UTC (rev 18514)
+++ short/3D/PyLith/trunk/libsrc/pylith/meshio/Xdmf.cc	2011-06-01 01:39:41 UTC (rev 18515)
@@ -68,6 +68,7 @@
   assert(2 == ndims);
   numVertices = dims[0];
   spaceDim = dims[1];
+  delete[] dims; dims = 0;
 
   if (1 == spaceDim) {
     std::cout
@@ -82,6 +83,7 @@
   assert(2 == ndims);
   numCells = dims[0];
   numCorners = dims[1];
+  delete[] dims; dims = 0;
   int cellDim = 0;
   h5.readAttribute("/topology/cells", "cell_dim", (void*)&cellDim, 
 		  H5T_NATIVE_INT);
@@ -223,6 +225,9 @@
       (*timeStamps)[i] = t[0];
     } // for
   } // if
+
+  delete[] dims; dims = 0;
+  delete[] t; t = 0;
 } // _getTimeStamps
 
 // ----------------------------------------------------------------------
@@ -276,6 +281,7 @@
 	(*metadata)[iOffset+i].numPoints = dims[1];
 	(*metadata)[iOffset+i].fiberDim = dims[2];
       } // if/else
+      delete[] dims; dims = 0;
     } // for
 
     iOffset += fieldNames.size();
@@ -318,6 +324,7 @@
 	(*metadata)[iOffset+i].numPoints = dims[1];
 	(*metadata)[iOffset+i].fiberDim = dims[2];
       } // if/else
+      delete[] dims; dims = 0;
     } // for
 
     iOffset += fieldNames.size();

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5.cc	2011-06-01 00:54:13 UTC (rev 18514)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestDataWriterHDF5.cc	2011-06-01 01:39:41 UTC (rev 18515)
@@ -113,6 +113,11 @@
       else
 	CPPUNIT_ASSERT_DOUBLES_EQUAL(dataE[i], data[i], tolerance);
 
+    delete[] dimsE; dimsE = 0;
+    delete[] dataE; dataE = 0;
+    delete[] dims; dims = 0;
+    delete[] data; data = 0;
+
     break;
   } // dataset
   default :

Modified: short/3D/PyLith/trunk/unittests/libtests/meshio/TestHDF5.cc
===================================================================
--- short/3D/PyLith/trunk/unittests/libtests/meshio/TestHDF5.cc	2011-06-01 00:54:13 UTC (rev 18514)
+++ short/3D/PyLith/trunk/unittests/libtests/meshio/TestHDF5.cc	2011-06-01 01:39:41 UTC (rev 18515)
@@ -125,6 +125,8 @@
 
   for (int i=0; i < ndimsE; ++i)
     CPPUNIT_ASSERT_EQUAL(dimsE[i], dims[i]);
+
+  delete[] dims; dims = 0;
 } // testGetDatasetDims
 
 // ----------------------------------------------------------------------



More information about the CIG-COMMITS mailing list