[MOAB-dev] r3585 - MOAB/trunk/itaps/imesh

kraftche at cae.wisc.edu kraftche at cae.wisc.edu
Wed Mar 10 18:30:43 CST 2010


Author: kraftche
Date: 2010-03-10 18:30:43 -0600 (Wed, 10 Mar 2010)
New Revision: 3585

Modified:
   MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
   MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp
Log:
fix bugs in my previous changes to iMesh error handling

o fix ERROR macro such that it returns correct error code and sets message
o make sure last error message is null-terminated
o back out Tim's work-around for the ERROR macro bug


Modified: MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
===================================================================
--- MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp	2010-03-10 22:21:01 UTC (rev 3584)
+++ MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp	2010-03-11 00:30:43 UTC (rev 3585)
@@ -645,7 +645,7 @@
         if (MB_SUCCESS != result) {
           if (allocated_array)
             free(array);
-          ERROR(iBase_ERROR_MAP[result], "iMesh_getEntArrAdj: trouble getting adjacency list.");
+          ERROR(result, "iMesh_getEntArrAdj: trouble getting adjacency list.");
         }
       }
       else if (iBase_ALL_TYPES == entity_type_requested) {
@@ -657,7 +657,7 @@
           if (MB_SUCCESS != result) {
             if (allocated_array)
               free(array);
-            ERROR(iBase_ERROR_MAP[result], "iMesh_getEntArrAdj: trouble getting adjacency list.");
+            ERROR(result, "iMesh_getEntArrAdj: trouble getting adjacency list.");
           }
         }
         connect = &adj_ents[0];
@@ -670,7 +670,7 @@
         if (MB_SUCCESS != result) {
           if (allocated_array)
             free(array);
-          ERROR(iBase_ERROR_MAP[result], "iMesh_getEntArrAdj: trouble getting adjacency list.");
+          ERROR(result, "iMesh_getEntArrAdj: trouble getting adjacency list.");
         }
         connect = &adj_ents[0];
         num_connect = adj_ents.size();
@@ -1408,7 +1408,7 @@
         msg += "Failed to create tag with name: \"";
       msg += tag_name;
       msg += "\".";
-      ERROR(iBase_ERROR_MAP[result],msg.c_str());
+      ERROR(result,msg.c_str());
     }
 
     *tag_handle = (iBase_TagHandle) new_tag;
@@ -1445,7 +1445,7 @@
       // ok, good to go - either forced or no entities with this tag
     MBErrorCode result = MBI->tag_delete(TAG_HANDLE(tag_handle));
     if (MB_SUCCESS != result && MB_TAG_NOT_FOUND != result)
-      ERROR(iBase_ERROR_MAP[result], "iMesh_destroyTag: problem deleting tag.");
+      ERROR(result, "iMesh_destroyTag: problem deleting tag.");
 
     RETURN(iBase_ERROR_MAP[result]);
   }
@@ -1525,7 +1525,7 @@
       std::string msg("iMesh_getTagHandle: problem getting handle for tag named '");
       msg += std::string(tag_name) + std::string("'");
       *tag_handle = 0;
-      ERROR(iBase_ERROR_MAP[result], msg.c_str());
+      ERROR(result, msg.c_str());
     }
 
     RETURN(iBase_SUCCESS);
@@ -1780,7 +1780,7 @@
       iMesh_getTagName(instance, tag_handle, tagn, &nerr, sizeof(tagn));
       snprintf(msg, sizeof(msg), "iMesh_getArrData: couldn't get size for tag \"%s\"",
                nerr==0?tagn:"unknown");
-      ERROR(iBase_ERROR_MAP[result], msg);
+      ERROR(result, msg);
     }
 
     if (0 == entity_handles_size) {
@@ -1805,7 +1805,7 @@
         message += name;
         message += "\".";
       }
-      ERROR(iBase_ERROR_MAP[result], message.c_str());
+      ERROR(result, message.c_str());
     }
 
     KEEP_ARRAY(tag_values);


Property changes on: MOAB/trunk/itaps/imesh/iMesh_MOAB.cpp
___________________________________________________________________
Deleted: svn:mergeinfo
   - 

Modified: MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp
===================================================================
--- MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp	2010-03-10 22:21:01 UTC (rev 3584)
+++ MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp	2010-03-11 00:30:43 UTC (rev 3585)
@@ -71,11 +71,12 @@
 {
   std::strncpy( iMesh_LAST_ERROR.description, desc,
                 sizeof(iMesh_LAST_ERROR.description) );
+  iMesh_LAST_ERROR.description[sizeof(iMesh_LAST_ERROR.description)-1] = '\0';
   iMesh_LAST_ERROR.error_type = (iBase_ErrorType)code;
 }
 
-#define ERROR(CODE,MSG) do { iMesh_setLastError( MBI, (CODE), (MSG) ); RETURN((CODE)); } while(false)
-#define IBASE_ERROR(CODE,MSG) iMesh_processError( *err = (CODE), (MSG) )
+#define ERROR(CODE,MSG) do { iMesh_setLastError( MBI, *err = (CODE), (MSG) ); return; } while(false)
+#define IBASE_ERROR(CODE,MSG) do { iMesh_processError( *err = (CODE), (MSG) ); return; } while(false)
 
 static inline void iMesh_setLastError( MBInterface*, int code, const char* msg )
   { iMesh_processError( code, msg ); }  


Property changes on: MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp
___________________________________________________________________
Deleted: svn:mergeinfo
   - 



More information about the moab-dev mailing list