Fixed memory allocation bug in CreateAdaptAdjacencies
authorAaron Becker <abecker3@illinois.edu>
Thu, 30 Aug 2007 21:01:14 +0000 (21:01 +0000)
committerAaron Becker <abecker3@illinois.edu>
Thu, 30 Aug 2007 21:01:14 +0000 (21:01 +0000)
src/libs/ck-libs/ParFUM/adapt_adj.C

index d897f9f49ff48c4d4f5fb9b1e8a966e8732199c5..0c1c43b76951dde3413c07d4ecaf2f928e63d80c 100644 (file)
@@ -177,7 +177,7 @@ void CreateAdaptAdjacencies(int meshid, int elemType)
     CkVec<adaptAdj>** adaptEdgeAdjacencies = edgeMapSize == 0 ?
         NULL :
         reinterpret_cast<CkVec<adaptAdj>**>(
-                (adaptAdjEdgeAttr->getInt()).getData());
+                (adaptAdjEdgeAttr->getChar()).getData());
 
     // Initialize adaptAdj arrays
     for (int i=0; i<numElems; i++) {
@@ -185,8 +185,12 @@ void CreateAdaptAdjacencies(int meshid, int elemType)
             adaptFaceAdjacencies[i*faceMapSize + j].partID = -1;
             adaptFaceAdjacencies[i*faceMapSize + j].localID = -1;
         }
-        if (adaptEdgeAdjacencies)
-            adaptEdgeAdjacencies[i] = new CkVec<adaptAdj>;
+        if (adaptEdgeAdjacencies) {
+            for (int j=0; j<edgeMapSize; ++j) {
+                adaptEdgeAdjacencies[i*edgeMapSize + j] = new CkVec<adaptAdj>;
+                assert(adaptEdgeAdjacencies[i*edgeMapSize + j] != NULL);
+            }
+        }
     }
 
     // Create an array of size equal to the number of local nodes, each