Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/markos-scratch 
into lp:zorba.

Commit message:
fixed memory leak during runtime group-by"

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/127433

fixed memory leak during runtime group-by
-- 
https://code.launchpad.net/~zorba-coders/zorba/markos-scratch/+merge/127433
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-10-01 08:15:43 +0000
+++ ChangeLog	2012-10-02 08:10:31 +0000
@@ -41,6 +41,7 @@
   * Fixed bug #950621 (Removed two-arg version of fn:parse-xml(); use XML module
     function xml:parse() instead)
   * Fixed bug #867227 (Improved error message for missing commas)
+  * Fixed memory leak during runtime group-by"
   * Fixed bug #1024033 and #1023170 (segfaults in parse-xml:parse())
   * Fixed bug #898792 (Dynamically computed strings can now be cast to xs:QName)
   * Fixed bug in determining the IsId property of constructed attribute nodes

=== modified file 'src/runtime/core/flwor_iterator.cpp'
--- src/runtime/core/flwor_iterator.cpp	2012-09-26 05:00:36 +0000
+++ src/runtime/core/flwor_iterator.cpp	2012-10-02 08:10:31 +0000
@@ -1456,7 +1456,7 @@
 {
   ZORBA_ASSERT(theGroupByClause);
 
-  GroupTuple* groupTuple = new GroupTuple();
+  std::auto_ptr<GroupTuple> groupTuple(new GroupTuple());
   std::vector<store::Item_t>& groupTupleItems = groupTuple->theItems;
 
   std::vector<GroupingSpec> groupSpecs = theGroupByClause->theGroupingSpecs;
@@ -1480,7 +1480,7 @@
   std::vector<store::TempSeq_t>* nongroupVarSequences = 0;
   csize numNonGroupingSpecs = nongroupingSpecs.size();
 
-  if (groupMap->get(groupTuple, nongroupVarSequences))
+  if (groupMap->get(groupTuple.get(), nongroupVarSequences))
   {
     for (csize i = 0; i < numNonGroupingSpecs; ++i)
     {
@@ -1491,8 +1491,6 @@
 
       nongroupingSpecs[i].reset(planState);
     }
-
-    delete groupTuple;
   }
   else
   {
@@ -1510,7 +1508,7 @@
       nongroupingSpecs[i].reset(planState);
     }
 
-    groupMap->insert(groupTuple, nongroupVarSequences);
+    groupMap->insert(groupTuple.release(), nongroupVarSequences);
   }
 }
 

=== modified file 'src/runtime/core/gflwor/groupby_iterator.cpp'
--- src/runtime/core/gflwor/groupby_iterator.cpp	2012-09-26 05:00:36 +0000
+++ src/runtime/core/gflwor/groupby_iterator.cpp	2012-10-02 08:10:31 +0000
@@ -356,7 +356,7 @@
 {
   store::Item_t temp;
 
-  GroupTuple* groupTuple = new GroupTuple();
+  std::auto_ptr<GroupTuple> groupTuple(new GroupTuple());
   std::vector<store::Item_t>& groupTupleItems = groupTuple->theItems;
 
   csize numVars = theGroupingSpecs.size();
@@ -383,7 +383,7 @@
 
   std::vector<store::TempSeq_t>* nonGroupTuple = NULL;
 
-  if (groupMap->get(groupTuple, nonGroupTuple)) 
+  if (groupMap->get(groupTuple.get(), nonGroupTuple))
   {
     assert(nonGroupTuple != NULL);
 
@@ -396,8 +396,6 @@
 
       theNonGroupingSpecs[i].theInput->reset(aPlanState);
     }
-
-    delete groupTuple;
   }
   else
   {
@@ -416,7 +414,7 @@
       theNonGroupingSpecs[i].theInput->reset(aPlanState);
     }
 
-    groupMap->insert(groupTuple, nonGroupTuple);
+    groupMap->insert(groupTuple.release(), nonGroupTuple);
   }
 }
 

-- 
Mailing list: https://launchpad.net/~zorba-coders
Post to     : zorba-coders@lists.launchpad.net
Unsubscribe : https://launchpad.net/~zorba-coders
More help   : https://help.launchpad.net/ListHelp

Reply via email to