[MOAB-dev] r3887 - MOAB/trunk/src/io

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed May 12 14:13:58 CDT 2010


Author: kraftche
Date: 2010-05-12 14:13:58 -0500 (Wed, 12 May 2010)
New Revision: 3887

Modified:
   MOAB/trunk/src/io/ReadHDF5.cpp
Log:
more debug output and error checking

Modified: MOAB/trunk/src/io/ReadHDF5.cpp
===================================================================
--- MOAB/trunk/src/io/ReadHDF5.cpp	2010-05-12 17:53:11 UTC (rev 3886)
+++ MOAB/trunk/src/io/ReadHDF5.cpp	2010-05-12 19:13:58 UTC (rev 3887)
@@ -63,7 +63,11 @@
 # include <errno.h>
 #endif
 
+#define assert_range( PTR, CNT ) \
+  assert( (PTR) >= (void*)dataBuffer ); assert( ((PTR)+(CNT)) <= (void*)(dataBuffer + bufferSize) );
 
+
+
 // This function doesn't do anything useful.  It's just a nice
 // place to set a break point to determine why the reader fails.
 static inline ErrorCode error( ErrorCode rval )
@@ -900,6 +904,7 @@
   long remaining = size, offset = 0;
   while (remaining) {
     long count = std::min( buffer_size, remaining );
+    assert_range( buffer, count );
     mhdf_readSparseTagEntitiesWithOpt( *tables, offset, count, 
                                 handleType, buffer, collIO, &status );
     if (is_error(status)) {
@@ -934,6 +939,7 @@
   while (remaining) {
       // Get a block of tag values
     size_t count = std::min( chunk_size, remaining );
+    assert_range( buffer, count );
     mhdf_readDenseTagWithOpt( tag_table, offset, count, H5T_NATIVE_UINT, buffer, collIO, &status );
     if (is_error(status))
       return error(MB_FAILURE);
@@ -1139,6 +1145,7 @@
       // read a block of connectivity data
     const long count = std::min( remaining, buffer_size );
     debug_track.record_io( offset, count );
+    assert_range( buffer, count*node_per_elem );
     mhdf_readConnectivityWithOpt( table_handle, offset, count, H5T_NATIVE_LONG, buffer, collIO, &status );
     if (is_error(status))
       return error(MB_FAILURE);
@@ -1238,6 +1245,7 @@
     
       // read element connectivity
     debug_track.record_io( offset, count );
+    assert_range( buffer, count*node_per_elem );
     mhdf_readConnectivityWithOpt( table, offset, count, handleType, buffer, indepIO, &status );
     if (is_error(status)) {
       mhdf_closeData( filePtr, table, &status );
@@ -1245,6 +1253,7 @@
     }
     


More information about the moab-dev mailing list