[MOAB-dev] r4507 - in MOAB/trunk/src/io: . mhdf/include mhdf/src

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed Feb 16 15:59:14 CST 2011


Author: kraftche
Date: 2011-02-16 15:59:14 -0600 (Wed, 16 Feb 2011)
New Revision: 4507

Modified:
   MOAB/trunk/src/io/ReadHDF5.cpp
   MOAB/trunk/src/io/WriteHDF5.cpp
   MOAB/trunk/src/io/mhdf/include/mhdf.h
   MOAB/trunk/src/io/mhdf/src/file.c
Log:
diagnostic code for detecting leaked HDF5 objects, and better handling of error encountering invalid connectivity when writing HDF5 files

Modified: MOAB/trunk/src/io/ReadHDF5.cpp
===================================================================
--- MOAB/trunk/src/io/ReadHDF5.cpp	2011-02-16 19:08:25 UTC (rev 4506)
+++ MOAB/trunk/src/io/ReadHDF5.cpp	2011-02-16 21:59:14 UTC (rev 4507)
@@ -49,6 +49,7 @@
 #include <string.h>
 #include <limits>
 #include <functional>
+#include <iostream>
 
 #ifdef BLUEGENE
 # include <sys/vfs.h>
@@ -145,6 +146,36 @@
 #endif
 }
 
+class CheckOpenReadHDF5Handles
+{
+  int fileline;
+  mhdf_FileHandle handle;
+  int enter_count;
+public:
+  CheckOpenReadHDF5Handles(mhdf_FileHandle file, int line)
+    : fileline(line), handle(file),
+      enter_count(mhdf_countOpenHandles(file))
+  {}
+  ~CheckOpenReadHDF5Handles()
+  {
+    int new_count = mhdf_countOpenHandles(handle);
+    if (new_count != enter_count) {
+      std::cout << "Leaked HDF5 object handle in function at " 
+                << __FILE__ << ":" << fileline << std::endl
+                << "Open at entrance: " << enter_count << std::endl
+                << "Open at exit:     " << new_count << std::endl;
+    }
+  }
+};
+
+
+#ifdef NDEBUG
+#define CHECK_OPEN_HANDLES
+#else
+#define CHECK_OPEN_HANDLES \
+  CheckOpenReadHDF5Handles check_open_handles_(filePtr,__LINE__)
+#endif
+
 ReaderIface* ReadHDF5::factory( Interface* iface )
   { return new ReadHDF5( iface ); }
 
@@ -530,6 +561,8 @@
   std::string tagname;


More information about the moab-dev mailing list