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

tautges at mcs.anl.gov tautges at mcs.anl.gov
Mon Apr 26 13:19:56 CDT 2010


Author: tautges
Date: 2010-04-26 13:19:56 -0500 (Mon, 26 Apr 2010)
New Revision: 3818

Modified:
   MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp
   MOAB/trunk/itaps/imesh/testc_cbind.c
Log:
Bug fix: iMesh convention states that for inout arrays, EITHER null
array ptr or zero alloc'd size indicates iMesh function should allocate
array space; only null array ptr was being checked before.  Also adding
a test that checks this behavior.



Modified: MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp
===================================================================
--- MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp	2010-04-26 16:31:58 UTC (rev 3817)
+++ MOAB/trunk/itaps/imesh/iMesh_MOAB.hpp	2010-04-26 18:19:56 UTC (rev 3818)
@@ -135,7 +135,7 @@
                      int val_size,
                      int* err ) : arrayPtr(0)
   {
-    if (!*array_ptr) {
+    if (!*array_ptr || !array_allocated_space) {
       *array_ptr = std::malloc(val_size * count);
       array_allocated_space = array_size = count;
       if (!*array_ptr) {

Modified: MOAB/trunk/itaps/imesh/testc_cbind.c
===================================================================
--- MOAB/trunk/itaps/imesh/testc_cbind.c	2010-04-26 16:31:58 UTC (rev 3817)
+++ MOAB/trunk/itaps/imesh/testc_cbind.c	2010-04-26 18:19:56 UTC (rev 3818)
@@ -86,6 +86,9 @@
   return FALSE;
 }
 
+#define CHK(err) if (err != iBase_SUCCESS)                              \
+    do {printf("%s:%d ITAPS error %d\n",__FILE__,__LINE__,err); return 0;} while (0)
+
 static iBase_EntitySetHandle root_set;
 
 /*!
@@ -2171,8 +2174,6 @@
     return 1;
 }
 
-#define CHK(err) if (err != iBase_SUCCESS)                              \
-    do {printf("%s:%d ITAPS error %d\n",__FILE__,__LINE__,err); return 0;} while (0)
 static int ordered_set_regression( iMesh_Instance mesh )
 {
   double coords[] = { 0,0,0, 1,1,1 };
@@ -2202,6 +2203,63 @@
   return 1;
 }
 
+int array_allocation( iMesh_Instance mesh )
+{
+  int err;
+
+  double coords[] = { 0,0,0, 1,1,1, 2,2,2, 3,3,3 };
+
+  iBase_EntityHandle *verts = NULL;
+  int verts_alloc = 0,verts_size;
+
+  iMesh_newMesh("",&mesh,&err,0);


More information about the moab-dev mailing list