← Back to team overview

zorba-coders team mailing list archive

[Merge] lp:~zorba-coders/zorba/bug-1038410 into lp:zorba

 

Markos Zaharioudakis has proposed merging lp:~zorba-coders/zorba/bug-1038410 into lp:zorba.

Requested reviews:
  Markos Zaharioudakis (markos-za)

For more details, see:
https://code.launchpad.net/~zorba-coders/zorba/bug-1038410/+merge/121543

Fixed bug #1038410 (Memory leaks in parser, trace iterator, and general index)
-- 
https://code.launchpad.net/~zorba-coders/zorba/bug-1038410/+merge/121543
Your team Zorba Coders is subscribed to branch lp:zorba.
=== modified file 'ChangeLog'
--- ChangeLog	2012-08-24 23:20:23 +0000
+++ ChangeLog	2012-08-28 07:06:22 +0000
@@ -2,14 +2,21 @@
 
 version 2.7
 
+New Features:
+  * Allow prolog variables to be referenced before they are declared (XQuery 3.0 feature)
+
 Bug Fixes/Other Changes:
   * Fixed bug #898792 (Dynamically computed strings can now be cast to xs:QName)
   * Fixed bugs #899364 and 899363 (throw XQST0103 in case of non-distinct window
     variables)
   * Fixed bug #899366 (enforce the type declaration of a window variable)
   * Fixed bug #1024892 (index declaration references udf declared after the index)
+<<<<<<< TREE
   * Fixed bug #1039488 (inserting more than one pair at once in a JSON object)
 
+=======
+  * Fixed bug #1038410 (Memory leaks in parser, trace iterator, and general index)
+>>>>>>> MERGE-SOURCE
 
 version 2.6
 

=== modified file 'src/compiler/parser/xquery_parser.y'
--- src/compiler/parser/xquery_parser.y	2012-08-16 18:31:02 +0000
+++ src/compiler/parser/xquery_parser.y	2012-08-28 07:06:22 +0000
@@ -2660,6 +2660,7 @@
       $$ = $3; // to prevent the Bison warning
       error(@2, "syntax error, unexpected QName \""
           + static_cast<VarInDeclList*>($3)->operator[](0)->get_var_name()->get_qname().str() + "\" (missing \"$\" sign?)");
+      delete $3;
       YYERROR;
     }
   |
@@ -2675,14 +2676,14 @@
 VarInDeclList :
     VarInDecl
     {
-      VarInDeclList *vdl = new VarInDeclList( LOC(@$) );
+      VarInDeclList* vdl = new VarInDeclList( LOC(@$) );
       vdl->push_back( dynamic_cast<VarInDecl*>($1) );
       $$ = vdl;
     }
   |
     VarInDeclList COMMA DOLLAR VarInDecl
     {
-      if ( VarInDeclList *vdl = dynamic_cast<VarInDeclList*>($1) )
+      if ( VarInDeclList* vdl = dynamic_cast<VarInDeclList*>($1) )
         vdl->push_back( dynamic_cast<VarInDecl*>($4) );
       $$ = $1;
     }
@@ -2693,6 +2694,7 @@
       $$ = $1; // to prevent the Bison warning
       error(@3, "syntax error, unexpected QName \""
           + static_cast<VarInDecl*>($3)->get_var_name()->get_qname().str() + "\" (missing \"$\" sign?)");
+      delete $1;
       YYERROR;
     }
 ;

=== modified file 'src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp'
--- src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp	2012-08-16 18:31:02 +0000
+++ src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp	2012-08-28 07:06:22 +0000
@@ -104,13 +104,13 @@
     );
   }
 
-  if (state->theSerializer.get() == 0) {
-    state->theSerializer.reset(new serializer(0));
+  if (state->theSerializer == 0)
+  {
+    state->theSerializer = new serializer(0);
+
     Zorba_SerializerOptions options;
     options.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
-    SerializerImpl::setSerializationParameters(
-                        *(state->theSerializer), 
-                        options);
+    SerializerImpl::setSerializationParameters(*(state->theSerializer), options);
   }
   state->theOS = theSctx->get_trace_stream();
 

=== modified file 'src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.cpp'
--- src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.cpp	2012-08-16 18:31:02 +0000
+++ src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.cpp	2012-08-28 07:06:22 +0000
@@ -29,6 +29,7 @@
 #include "system/globalenv.h"
 
 
+#include "api/serialization/serializer.h"
 
 namespace zorba {
 
@@ -95,7 +96,7 @@
   theTagItem = NULL;
   theIndex = 0;
   theOS = 0;
-  theSerializer = std::auto_ptr<serializer>(0);
+  theSerializer = NULL;
 }
 
 void TraceIteratorState::reset(PlanState& planState) {
@@ -103,7 +104,7 @@
   theTagItem = NULL;
   theIndex = 0;
   theOS = 0;
-  theSerializer = std::auto_ptr<serializer>(0);
+  theSerializer = NULL;
 }
 // </TraceIterator>
 

=== modified file 'src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.h'
--- src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.h	2012-08-16 18:31:02 +0000
+++ src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.h	2012-08-28 07:06:22 +0000
@@ -73,7 +73,7 @@
   store::Item_t theTagItem; //
   uint32_t theIndex; //
   std::ostream* theOS; //
-  std::auto_ptr<serializer> theSerializer; //
+  rchandle<serializer> theSerializer; //
 
   TraceIteratorState();
 

=== modified file 'src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml'
--- src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml	2012-08-16 18:31:02 +0000
+++ src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml	2012-08-28 07:06:22 +0000
@@ -11,7 +11,11 @@
   xmlns:zorba="http://www.zorba-xquery.com";
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
   xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
-    
+
+<zorba:source>
+    <zorba:include form="Quoted">api/serialization/serializer.h</zorba:include>
+</zorba:source>
+
 <!--
 /*******************************************************************************
  * 3.1.1 fn:error
@@ -88,9 +92,8 @@
       <zorba:member type="store::Item_t" name="theTagItem" defaultValue="NULL" brief=""/>
       <zorba:member type="uint32_t" name="theIndex" defaultValue="0" brief=""/>
       <zorba:member type="std::ostream*" name="theOS" defaultValue="0" brief=""/>
-      <zorba:member type="std::auto_ptr&lt;serializer&gt;"
-                    name="theSerializer"
-                    defaultValue="std::auto_ptr&lt;serializer&gt;(0)"
+      <zorba:member type="rchandle&lt;serializer&gt;" name="theSerializer"
+                    defaultValue="NULL"
                     brief=""/>
     </zorba:state>
     

=== modified file 'src/store/naive/qname_pool.cpp'
--- src/store/naive/qname_pool.cpp	2012-08-16 18:31:02 +0000
+++ src/store/naive/qname_pool.cpp	2012-08-28 07:06:22 +0000
@@ -371,8 +371,9 @@
     {
       theCache[qn->thePrevFree].theNextFree = qn->theNextFree;
     }
-    else if (theFirstFree == qn->thePosition)
+    else
     {
+      assert(theFirstFree == qn->thePosition);
       theFirstFree = qn->theNextFree;
     }
 

=== modified file 'src/store/naive/simple_index_general.cpp'
--- src/store/naive/simple_index_general.cpp	2012-08-16 18:31:02 +0000
+++ src/store/naive/simple_index_general.cpp	2012-08-28 07:06:22 +0000
@@ -1149,6 +1149,33 @@
 /******************************************************************************
 
 *******************************************************************************/
+void GeneralHashIndex::clear()
+{
+  for (csize i = 0; i < store::XS_LAST; ++i)
+  {
+    if (theMaps[i] == NULL)
+      continue;
+
+    IndexMap::iterator ite = theMaps[i]->begin();
+    IndexMap::iterator end = theMaps[i]->end();
+ 
+    for (; ite != end; ++ite)
+    {
+      //std::cout << "Index Entry Delete [" << (*ite).first << "," 
+      //          << (*ite).second << "]" << std::endl;
+      
+      const_cast<store::Item*>((*ite).first)->removeReference();
+      delete (*ite).second;
+    }
+
+    theMaps[i]->clear();
+  }
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
 store::Index::KeyIterator_t GeneralHashIndex::keys() const
 {
   return new KeyIterator(theMaps);
@@ -1228,26 +1255,6 @@
 }
 
 
-/******************************************************************************
-
-*******************************************************************************/
-void GeneralHashIndex::clear()
-{
-  for (csize i = 0; i < store::XS_LAST; ++i)
-  {
-    if (theMaps[i] == NULL)
-      continue;
-
-    theMaps[i]->clear();
-  }
-
-  if (isTyped())
-  {
-    theSingleMap->clear();
-  }
-}
-
-
 /////////////////////////////////////////////////////////////////////////////////
 //                                                                             //
 //  GeneralHashIndex::KeyIterator                                              //
@@ -1396,6 +1403,33 @@
 /******************************************************************************
 
 *******************************************************************************/
+void GeneralTreeIndex::clear()
+{
+  for (csize i = 0; i < store::XS_LAST; ++i)
+  {
+    if (theMaps[i] == NULL)
+      continue;
+
+    IndexMap::iterator ite = theMaps[i]->begin();
+    IndexMap::iterator end = theMaps[i]->end();
+ 
+    for (; ite != end; ++ite)
+    {
+      //std::cout << "Index Entry Delete [" << (*ite).first << "," 
+      //          << (*ite).second << "]" << std::endl;
+      
+      const_cast<store::Item*>((*ite).first)->removeReference();
+      delete (*ite).second;
+    }
+
+    theMaps[i]->clear();
+  }
+}
+
+
+/******************************************************************************
+
+*******************************************************************************/
 bool GeneralTreeIndex::insertInMap(
     store::Item_t& key,
     store::Item_t& node,
@@ -1471,26 +1505,6 @@
 /******************************************************************************
 
 *******************************************************************************/
-void GeneralTreeIndex::clear()
-{
-  for (csize i = 0; i < store::XS_LAST; ++i)
-  {
-    if (theMaps[i] == NULL)
-      continue;
-
-    theMaps[i]->clear();
-  }
-
-  if (isTyped())
-  {
-    theSingleMap->clear();
-  }
-}
-
-
-/******************************************************************************
-
-*******************************************************************************/
 store::Index::KeyIterator_t GeneralTreeIndex::keys() const
 {
   return 0;


Follow ups