[MOAB-dev] r3787 - MOAB/trunk/src/parallel

tautges at mcs.anl.gov tautges at mcs.anl.gov
Fri Apr 16 16:30:59 CDT 2010


Author: tautges
Date: 2010-04-16 16:30:59 -0500 (Fri, 16 Apr 2010)
New Revision: 3787

Modified:
   MOAB/trunk/src/parallel/ParallelComm.cpp
Log:
Be more careful about using memcpy to copy into/out of buffers;
casting to double* and EH* doesn't work when straddling 8-byte
boundaries.

Passes tests in parallel and serial.



Modified: MOAB/trunk/src/parallel/ParallelComm.cpp
===================================================================
--- MOAB/trunk/src/parallel/ParallelComm.cpp	2010-04-16 18:44:04 UTC (rev 3786)
+++ MOAB/trunk/src/parallel/ParallelComm.cpp	2010-04-16 21:30:59 UTC (rev 3787)
@@ -117,17 +117,21 @@
   { PACK_INTS( buff, &int_val, 1 ); }
 
 static inline
-void PACK_DBL( unsigned char*& buff, const double* dbl_val, size_t num )
+void PACK_DBLS( unsigned char*& buff, const double* dbl_val, size_t num )
   { PACK( buff, dbl_val, num ); PC(num, " doubles"); }
 
 static inline
+void PACK_DBL( unsigned char*& buff, const double dbl_val)
+{ PACK_DBLS( buff, &dbl_val, 1 ); }
+
+static inline
 void PACK_EH( unsigned char*& buff, const EntityHandle* eh_val, size_t num )
   { PACK( buff, eh_val, num ); PC(num, " handles"); }
 
 static inline
 void PACK_CHAR_64( unsigned char*& buff, const char* str )
 {
-  strncpy( reinterpret_cast<char*>(buff), str, 64 );
+  memcpy(buff, str, 64 );
   buff += 64;
   PC(64, " chars");
 }
@@ -164,10 +168,14 @@
   { UNPACK_INTS( buff, &int_val, 1 ); }
 
 static inline
-void UNPACK_DBL( unsigned char*& buff, double* dbl_val, size_t num )
+void UNPACK_DBLS( unsigned char*& buff, double* dbl_val, size_t num )
   { UNPACK(buff, dbl_val, num); UPC(num, " doubles"); }
 
 static inline
+void UNPACK_DBL( unsigned char*& buff, double &dbl_val)
+{ UNPACK_DBLS(buff, &dbl_val, 1); }
+
+static inline
 void UNPACK_EH( unsigned char*& buff, EntityHandle* eh_val, size_t num )
   { UNPACK(buff, eh_val, num); UPC(num, " handles"); }
 
@@ -841,12 +849,11 @@
     PACK_INT(buff->buff_ptr, ((int) MBVERTEX));
     PACK_INT(buff->buff_ptr, ((int) num_ents));
 
-    result = mbImpl->get_coords(these_ents, (double*)buff->buff_ptr);
+    std::vector<double> tmp_coords(3*num_ents);
+    result = mbImpl->get_coords(these_ents, &tmp_coords[0]);


More information about the moab-dev mailing list