Fixing memory leaks reported by Valgrind in message logging layer.
authorEsteban Meneses <emenese2@illinois.edu>
Mon, 4 Jun 2012 17:02:52 +0000 (12:02 -0500)
committerEsteban Meneses <emenese2@illinois.edu>
Mon, 4 Jun 2012 17:02:52 +0000 (12:02 -0500)
src/ck-core/cklocation.C

index 0d49f64a8354af5f2930e7ba82a4ad085d7f2911..a5d7431679b0c23ea5286307c08167709f867560 100644 (file)
@@ -1851,15 +1851,18 @@ void CkLocMgr::flushAllRecs(void)
 
 #if (defined(_FAULT_MLOG_) || defined(_FAULT_CAUSAL_))
 void CkLocMgr::callForAllRecords(CkLocFn fnPointer,CkArray *arr,void *data){
-    void *objp;
-    void *keyp;
+       void *objp;
+       void *keyp;
+
+       CkHashtableIterator *it = hash.iterator();
+       while (NULL!=(objp=it->next(&keyp))) {
+               CkLocRec *rec=*(CkLocRec **)objp;
+               CkArrayIndex &idx=*(CkArrayIndex *)keyp;
+               fnPointer(arr,data,rec,&idx);
+       }
 
-    CkHashtableIterator *it = hash.iterator();
-  while (NULL!=(objp=it->next(&keyp))) {
-    CkLocRec *rec=*(CkLocRec **)objp;
-    CkArrayIndex &idx=*(CkArrayIndex *)keyp;
-        fnPointer(arr,data,rec,&idx);
-    }
+       // releasing iterator memory
+       delete it;
 }
 #endif
 
@@ -1969,6 +1972,9 @@ void CkLocMgr::pup(PUP::er &p){
         p | count;
         DEBUG(CmiPrintf("[%d] Packing Locmgr %d has %d home elements\n",CmiMyPe(),thisgroup.idx,count));
 
+               // releasing iterator memory
+               delete it;
+
         it = hash.iterator();
       while (NULL!=(objp=it->next(&keyp))) {
       CkLocRec *rec=*(CkLocRec **)objp;
@@ -1986,6 +1992,9 @@ void CkLocMgr::pup(PUP::er &p){
         }
         CmiAssert(count == count1);
 
+               // releasing iterator memory
+               delete it;
+
 #endif
 
        }