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

Proposed by Markos Zaharioudakis
Status: Merged
Approved by: Markos Zaharioudakis
Approved revision: 10993
Merged at revision: 11004
Proposed branch: lp:~zorba-coders/zorba/bug-1038410
Merge into: lp:zorba
Diff against target: 293 lines (+80/-55)
8 files modified
ChangeLog (+4/-0)
src/compiler/parser/xquery_parser.y (+4/-2)
src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp (+5/-5)
src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.cpp (+3/-2)
src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.h (+1/-1)
src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml (+7/-4)
src/store/naive/qname_pool.cpp (+2/-1)
src/store/naive/simple_index_general.cpp (+54/-40)
To merge this branch: bzr merge lp:~zorba-coders/zorba/bug-1038410
Reviewer Review Type Date Requested Status
Markos Zaharioudakis Approve
Review via email: mp+121543@code.launchpad.net

Commit message

Fixed bug #1038410 (Memory leaks in parser, trace iterator, and general index)

Description of the change

Fixed bug #1038410 (Memory leaks in parser, trace iterator, and general index)

To post a comment you must log in.
lp:~zorba-coders/zorba/bug-1038410 updated
10993. By Markos Zaharioudakis

merge from trunk

Revision history for this message
Markos Zaharioudakis (markos-za) :
review: Approve
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :
Revision history for this message
Zorba Build Bot (zorba-buildbot) wrote :

Validation queue job bug-1038410-2012-08-28T07-23-03.04Z is finished. The final status was:

All tests succeeded!

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ChangeLog'
2--- ChangeLog 2012-08-24 23:20:23 +0000
3+++ ChangeLog 2012-08-28 07:18:34 +0000
4@@ -2,12 +2,16 @@
5
6 version 2.7
7
8+New Features:
9+ * Allow prolog variables to be referenced before they are declared (XQuery 3.0 feature)
10+
11 Bug Fixes/Other Changes:
12 * Fixed bug #898792 (Dynamically computed strings can now be cast to xs:QName)
13 * Fixed bugs #899364 and 899363 (throw XQST0103 in case of non-distinct window
14 variables)
15 * Fixed bug #899366 (enforce the type declaration of a window variable)
16 * Fixed bug #1024892 (index declaration references udf declared after the index)
17+ * Fixed bug #1038410 (Memory leaks in parser, trace iterator, and general index)
18 * Fixed bug #1039488 (inserting more than one pair at once in a JSON object)
19
20
21
22=== modified file 'src/compiler/parser/xquery_parser.y'
23--- src/compiler/parser/xquery_parser.y 2012-08-16 18:31:02 +0000
24+++ src/compiler/parser/xquery_parser.y 2012-08-28 07:18:34 +0000
25@@ -2660,6 +2660,7 @@
26 $$ = $3; // to prevent the Bison warning
27 error(@2, "syntax error, unexpected QName \""
28 + static_cast<VarInDeclList*>($3)->operator[](0)->get_var_name()->get_qname().str() + "\" (missing \"$\" sign?)");
29+ delete $3;
30 YYERROR;
31 }
32 |
33@@ -2675,14 +2676,14 @@
34 VarInDeclList :
35 VarInDecl
36 {
37- VarInDeclList *vdl = new VarInDeclList( LOC(@$) );
38+ VarInDeclList* vdl = new VarInDeclList( LOC(@$) );
39 vdl->push_back( dynamic_cast<VarInDecl*>($1) );
40 $$ = vdl;
41 }
42 |
43 VarInDeclList COMMA DOLLAR VarInDecl
44 {
45- if ( VarInDeclList *vdl = dynamic_cast<VarInDeclList*>($1) )
46+ if ( VarInDeclList* vdl = dynamic_cast<VarInDeclList*>($1) )
47 vdl->push_back( dynamic_cast<VarInDecl*>($4) );
48 $$ = $1;
49 }
50@@ -2693,6 +2694,7 @@
51 $$ = $1; // to prevent the Bison warning
52 error(@3, "syntax error, unexpected QName \""
53 + static_cast<VarInDecl*>($3)->get_var_name()->get_qname().str() + "\" (missing \"$\" sign?)");
54+ delete $1;
55 YYERROR;
56 }
57 ;
58
59=== modified file 'src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp'
60--- src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp 2012-08-16 18:31:02 +0000
61+++ src/runtime/errors_and_diagnostics/errors_and_diagnostics_impl.cpp 2012-08-28 07:18:34 +0000
62@@ -104,13 +104,13 @@
63 );
64 }
65
66- if (state->theSerializer.get() == 0) {
67- state->theSerializer.reset(new serializer(0));
68+ if (state->theSerializer == 0)
69+ {
70+ state->theSerializer = new serializer(0);
71+
72 Zorba_SerializerOptions options;
73 options.omit_xml_declaration = ZORBA_OMIT_XML_DECLARATION_YES;
74- SerializerImpl::setSerializationParameters(
75- *(state->theSerializer),
76- options);
77+ SerializerImpl::setSerializationParameters(*(state->theSerializer), options);
78 }
79 state->theOS = theSctx->get_trace_stream();
80
81
82=== modified file 'src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.cpp'
83--- src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.cpp 2012-08-16 18:31:02 +0000
84+++ src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.cpp 2012-08-28 07:18:34 +0000
85@@ -29,6 +29,7 @@
86 #include "system/globalenv.h"
87
88
89+#include "api/serialization/serializer.h"
90
91 namespace zorba {
92
93@@ -95,7 +96,7 @@
94 theTagItem = NULL;
95 theIndex = 0;
96 theOS = 0;
97- theSerializer = std::auto_ptr<serializer>(0);
98+ theSerializer = NULL;
99 }
100
101 void TraceIteratorState::reset(PlanState& planState) {
102@@ -103,7 +104,7 @@
103 theTagItem = NULL;
104 theIndex = 0;
105 theOS = 0;
106- theSerializer = std::auto_ptr<serializer>(0);
107+ theSerializer = NULL;
108 }
109 // </TraceIterator>
110
111
112=== modified file 'src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.h'
113--- src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.h 2012-08-16 18:31:02 +0000
114+++ src/runtime/errors_and_diagnostics/pregenerated/errors_and_diagnostics.h 2012-08-28 07:18:34 +0000
115@@ -73,7 +73,7 @@
116 store::Item_t theTagItem; //
117 uint32_t theIndex; //
118 std::ostream* theOS; //
119- std::auto_ptr<serializer> theSerializer; //
120+ rchandle<serializer> theSerializer; //
121
122 TraceIteratorState();
123
124
125=== modified file 'src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml'
126--- src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml 2012-08-16 18:31:02 +0000
127+++ src/runtime/spec/errors_and_diagnostics/errors_and_diagnostics.xml 2012-08-28 07:18:34 +0000
128@@ -11,7 +11,11 @@
129 xmlns:zorba="http://www.zorba-xquery.com"
130 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
131 xsi:schemaLocation="http://www.zorba-xquery.com ../runtime.xsd">
132-
133+
134+<zorba:source>
135+ <zorba:include form="Quoted">api/serialization/serializer.h</zorba:include>
136+</zorba:source>
137+
138 <!--
139 /*******************************************************************************
140 * 3.1.1 fn:error
141@@ -88,9 +92,8 @@
142 <zorba:member type="store::Item_t" name="theTagItem" defaultValue="NULL" brief=""/>
143 <zorba:member type="uint32_t" name="theIndex" defaultValue="0" brief=""/>
144 <zorba:member type="std::ostream*" name="theOS" defaultValue="0" brief=""/>
145- <zorba:member type="std::auto_ptr&lt;serializer&gt;"
146- name="theSerializer"
147- defaultValue="std::auto_ptr&lt;serializer&gt;(0)"
148+ <zorba:member type="rchandle&lt;serializer&gt;" name="theSerializer"
149+ defaultValue="NULL"
150 brief=""/>
151 </zorba:state>
152
153
154=== modified file 'src/store/naive/qname_pool.cpp'
155--- src/store/naive/qname_pool.cpp 2012-08-16 18:31:02 +0000
156+++ src/store/naive/qname_pool.cpp 2012-08-28 07:18:34 +0000
157@@ -371,8 +371,9 @@
158 {
159 theCache[qn->thePrevFree].theNextFree = qn->theNextFree;
160 }
161- else if (theFirstFree == qn->thePosition)
162+ else
163 {
164+ assert(theFirstFree == qn->thePosition);
165 theFirstFree = qn->theNextFree;
166 }
167
168
169=== modified file 'src/store/naive/simple_index_general.cpp'
170--- src/store/naive/simple_index_general.cpp 2012-08-16 18:31:02 +0000
171+++ src/store/naive/simple_index_general.cpp 2012-08-28 07:18:34 +0000
172@@ -1149,6 +1149,33 @@
173 /******************************************************************************
174
175 *******************************************************************************/
176+void GeneralHashIndex::clear()
177+{
178+ for (csize i = 0; i < store::XS_LAST; ++i)
179+ {
180+ if (theMaps[i] == NULL)
181+ continue;
182+
183+ IndexMap::iterator ite = theMaps[i]->begin();
184+ IndexMap::iterator end = theMaps[i]->end();
185+
186+ for (; ite != end; ++ite)
187+ {
188+ //std::cout << "Index Entry Delete [" << (*ite).first << ","
189+ // << (*ite).second << "]" << std::endl;
190+
191+ const_cast<store::Item*>((*ite).first)->removeReference();
192+ delete (*ite).second;
193+ }
194+
195+ theMaps[i]->clear();
196+ }
197+}
198+
199+
200+/******************************************************************************
201+
202+*******************************************************************************/
203 store::Index::KeyIterator_t GeneralHashIndex::keys() const
204 {
205 return new KeyIterator(theMaps);
206@@ -1228,26 +1255,6 @@
207 }
208
209
210-/******************************************************************************
211-
212-*******************************************************************************/
213-void GeneralHashIndex::clear()
214-{
215- for (csize i = 0; i < store::XS_LAST; ++i)
216- {
217- if (theMaps[i] == NULL)
218- continue;
219-
220- theMaps[i]->clear();
221- }
222-
223- if (isTyped())
224- {
225- theSingleMap->clear();
226- }
227-}
228-
229-
230 /////////////////////////////////////////////////////////////////////////////////
231 // //
232 // GeneralHashIndex::KeyIterator //
233@@ -1396,6 +1403,33 @@
234 /******************************************************************************
235
236 *******************************************************************************/
237+void GeneralTreeIndex::clear()
238+{
239+ for (csize i = 0; i < store::XS_LAST; ++i)
240+ {
241+ if (theMaps[i] == NULL)
242+ continue;
243+
244+ IndexMap::iterator ite = theMaps[i]->begin();
245+ IndexMap::iterator end = theMaps[i]->end();
246+
247+ for (; ite != end; ++ite)
248+ {
249+ //std::cout << "Index Entry Delete [" << (*ite).first << ","
250+ // << (*ite).second << "]" << std::endl;
251+
252+ const_cast<store::Item*>((*ite).first)->removeReference();
253+ delete (*ite).second;
254+ }
255+
256+ theMaps[i]->clear();
257+ }
258+}
259+
260+
261+/******************************************************************************
262+
263+*******************************************************************************/
264 bool GeneralTreeIndex::insertInMap(
265 store::Item_t& key,
266 store::Item_t& node,
267@@ -1471,26 +1505,6 @@
268 /******************************************************************************
269
270 *******************************************************************************/
271-void GeneralTreeIndex::clear()
272-{
273- for (csize i = 0; i < store::XS_LAST; ++i)
274- {
275- if (theMaps[i] == NULL)
276- continue;
277-
278- theMaps[i]->clear();
279- }
280-
281- if (isTyped())
282- {
283- theSingleMap->clear();
284- }
285-}
286-
287-
288-/******************************************************************************
289-
290-*******************************************************************************/
291 store::Index::KeyIterator_t GeneralTreeIndex::keys() const
292 {
293 return 0;

Subscribers

People subscribed via source and target branches