Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
qbox-public
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
qbox
qbox-public
Commits
707eaddd
Commit
707eaddd
authored
Aug 01, 2018
by
Francois Gygi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use StrX in XML handler classes to avoid mem leaks
parent
c4e49cf0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
32 deletions
+30
-32
AtomSetHandler.C
src/AtomSetHandler.C
+8
-8
SampleHandler.C
src/SampleHandler.C
+2
-2
SpeciesHandler.C
src/SpeciesHandler.C
+4
-6
WavefunctionHandler.C
src/WavefunctionHandler.C
+16
-16
No files found.
src/AtomSetHandler.C
View file @
707eaddd
...
@@ -42,7 +42,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
...
@@ -42,7 +42,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
const
Attributes
&
attributes
)
const
Attributes
&
attributes
)
{
{
// cout << " AtomSetHandler::startElement " << StrX(qname) << endl;
// cout << " AtomSetHandler::startElement " << StrX(qname) << endl;
string
locname
(
XMLString
::
transcode
(
localname
)
);
string
locname
=
StrX
(
localname
).
localForm
(
);
// consider only elements that are dealt with directly by AtomSetHandler
// consider only elements that are dealt with directly by AtomSetHandler
// i.e. "atom". The "species" element is delegated to a SpeciesHandler
// i.e. "atom". The "species" element is delegated to a SpeciesHandler
...
@@ -52,8 +52,8 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
...
@@ -52,8 +52,8 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
string
attrval
(
XMLString
::
transcode
(
attributes
.
getValue
(
index
))
);
string
attrval
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
(
);
istringstream
stst
(
attrval
);
istringstream
stst
(
attrval
);
if
(
attrname
==
"a"
)
if
(
attrname
==
"a"
)
{
{
...
@@ -79,7 +79,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
...
@@ -79,7 +79,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
if
(
attrname
==
"name"
)
if
(
attrname
==
"name"
)
{
{
current_atom_name
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
();
current_atom_name
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
();
...
@@ -96,7 +96,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
...
@@ -96,7 +96,7 @@ void AtomSetHandler::startElement(const XMLCh* const uri,
void
AtomSetHandler
::
endElement
(
const
XMLCh
*
const
uri
,
void
AtomSetHandler
::
endElement
(
const
XMLCh
*
const
uri
,
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
string
&
content
)
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
string
&
content
)
{
{
string
locname
(
XMLString
::
transcode
(
localname
)
);
string
locname
=
StrX
(
localname
).
localForm
(
);
// cout << " AtomSetHandler::endElement " << locname << endl;
// cout << " AtomSetHandler::endElement " << locname << endl;
istringstream
stst
(
content
);
istringstream
stst
(
content
);
if
(
locname
==
"unit_cell"
)
if
(
locname
==
"unit_cell"
)
...
@@ -146,14 +146,14 @@ StructureHandler* AtomSetHandler::startSubHandler(const XMLCh* const uri,
...
@@ -146,14 +146,14 @@ StructureHandler* AtomSetHandler::startSubHandler(const XMLCh* const uri,
// If it can, return a pointer to the StructureHandler, otherwise return 0
// If it can, return a pointer to the StructureHandler, otherwise return 0
// cout << " AtomSetHandler::startSubHandler " << StrX(qname) << endl;
// cout << " AtomSetHandler::startSubHandler " << StrX(qname) << endl;
string
locname
(
XMLString
::
transcode
(
localname
)
);
string
locname
=
StrX
(
localname
).
localForm
(
);
if
(
locname
==
"species"
)
if
(
locname
==
"species"
)
{
{
// check for species attributes
// check for species attributes
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
if
(
attrname
==
"name"
)
if
(
attrname
==
"name"
)
{
{
current_species_name
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
();
current_species_name
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
();
...
@@ -175,7 +175,7 @@ void AtomSetHandler::endSubHandler(const XMLCh* const uri,
...
@@ -175,7 +175,7 @@ void AtomSetHandler::endSubHandler(const XMLCh* const uri,
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
const
StructureHandler
*
const
last
)
const
StructureHandler
*
const
last
)
{
{
string
locname
(
XMLString
::
transcode
(
localname
)
);
string
locname
=
StrX
(
localname
).
localForm
(
);
// cout << " AtomSetHandler::endSubHandler " << locname << endl;
// cout << " AtomSetHandler::endSubHandler " << locname << endl;
if
(
locname
==
"species"
)
if
(
locname
==
"species"
)
{
{
...
...
src/SampleHandler.C
View file @
707eaddd
...
@@ -46,7 +46,7 @@ void SampleHandler::endElement(const XMLCh* const uri,
...
@@ -46,7 +46,7 @@ void SampleHandler::endElement(const XMLCh* const uri,
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
string
&
content
)
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
string
&
content
)
{
{
// istringstream stst(st);
// istringstream stst(st);
// string locname
(XMLString::transcode(localname)
);
// string locname
= StrX(localname).localForm(
);
// cout << " SampleHandler::endElement " << locname << endl;
// cout << " SampleHandler::endElement " << locname << endl;
}
}
...
@@ -59,7 +59,7 @@ StructureHandler* SampleHandler::startSubHandler(const XMLCh* const uri,
...
@@ -59,7 +59,7 @@ StructureHandler* SampleHandler::startSubHandler(const XMLCh* const uri,
// If it can, return a pointer to the StructureHandler, otherwise return 0
// If it can, return a pointer to the StructureHandler, otherwise return 0
// cout << " SampleHandler::startSubHandler " << StrX(qname) << endl;
// cout << " SampleHandler::startSubHandler " << StrX(qname) << endl;
string
qnm
=
XMLString
::
transcode
(
qname
);
string
qnm
=
StrX
(
qname
).
localForm
(
);
if
(
qnm
==
"atomset"
)
if
(
qnm
==
"atomset"
)
{
{
return
new
AtomSetHandler
(
s_
.
atoms
);
return
new
AtomSetHandler
(
s_
.
atoms
);
...
...
src/SpeciesHandler.C
View file @
707eaddd
...
@@ -39,7 +39,7 @@ void SpeciesHandler::read(const Attributes& attributes)
...
@@ -39,7 +39,7 @@ void SpeciesHandler::read(const Attributes& attributes)
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
if
(
attrname
==
"l"
)
if
(
attrname
==
"l"
)
{
{
current_l
=
atoi
(
StrX
(
attributes
.
getValue
(
index
)).
localForm
());
current_l
=
atoi
(
StrX
(
attributes
.
getValue
(
index
)).
localForm
());
...
@@ -84,7 +84,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
...
@@ -84,7 +84,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
{
{
// cout << " SpeciesHandler::startElement " << StrX(qname) << endl;
// cout << " SpeciesHandler::startElement " << StrX(qname) << endl;
string
locname
(
XMLString
::
transcode
(
localname
)
);
string
locname
=
StrX
(
localname
).
localForm
(
);
if
(
locname
==
"species"
)
if
(
locname
==
"species"
)
{
{
...
@@ -92,7 +92,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
...
@@ -92,7 +92,7 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
if
(
attrname
==
"name"
)
if
(
attrname
==
"name"
)
{
{
current_name
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
();
current_name
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
();
...
@@ -135,10 +135,8 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
...
@@ -135,10 +135,8 @@ void SpeciesHandler::startElement(const XMLCh* const uri,
void
SpeciesHandler
::
endElement
(
const
XMLCh
*
const
uri
,
void
SpeciesHandler
::
endElement
(
const
XMLCh
*
const
uri
,
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
string
&
content
)
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
string
&
content
)
{
{
string
locname
(
XMLString
::
transcode
(
localname
)
);
string
locname
=
StrX
(
localname
).
localForm
(
);
istringstream
stst
(
content
);
istringstream
stst
(
content
);
// cout << " SpeciesHandler::endElement " << StrX(qname) << " content="
// << string(content,0,20) << endl;
if
(
locname
==
"description"
)
if
(
locname
==
"description"
)
{
{
...
...
src/WavefunctionHandler.C
View file @
707eaddd
...
@@ -65,7 +65,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
...
@@ -65,7 +65,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
{
{
bool
onpe0
=
wf_
.
context
().
onpe0
();
bool
onpe0
=
wf_
.
context
().
onpe0
();
// cout << " WavefunctionHandler::startElement " << StrX(qname) << endl;
// cout << " WavefunctionHandler::startElement " << StrX(qname) << endl;
string
locname
(
XMLString
::
transcode
(
localname
)
);
string
locname
=
StrX
(
localname
).
localForm
(
);
int
nspin
=
1
,
nel
=
0
,
nempty
=
0
;
int
nspin
=
1
,
nel
=
0
,
nempty
=
0
;
...
@@ -76,7 +76,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
...
@@ -76,7 +76,7 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
if
(
attrname
==
"ecut"
)
if
(
attrname
==
"ecut"
)
{
{
ecut
=
atof
(
StrX
(
attributes
.
getValue
(
index
)).
localForm
());
ecut
=
atof
(
StrX
(
attributes
.
getValue
(
index
)).
localForm
());
...
@@ -116,8 +116,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
...
@@ -116,8 +116,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
string
attrval
(
XMLString
::
transcode
(
attributes
.
getValue
(
index
))
);
string
attrval
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
(
);
istringstream
stst
(
attrval
);
istringstream
stst
(
attrval
);
if
(
attrname
==
"a"
)
if
(
attrname
==
"a"
)
{
{
...
@@ -143,8 +143,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
...
@@ -143,8 +143,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
string
attrval
(
XMLString
::
transcode
(
attributes
.
getValue
(
index
))
);
string
attrval
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
(
);
istringstream
stst
(
attrval
);
istringstream
stst
(
attrval
);
if
(
attrname
==
"a"
)
if
(
attrname
==
"a"
)
{
{
...
@@ -171,8 +171,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
...
@@ -171,8 +171,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
string
dmat_form
;
string
dmat_form
;
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
string
attrval
(
XMLString
::
transcode
(
attributes
.
getValue
(
index
))
);
string
attrval
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
(
);
istringstream
stst
(
attrval
);
istringstream
stst
(
attrval
);
if
(
attrname
==
"form"
)
if
(
attrname
==
"form"
)
{
{
...
@@ -195,8 +195,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
...
@@ -195,8 +195,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
string
attrval
(
XMLString
::
transcode
(
attributes
.
getValue
(
index
))
);
string
attrval
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
(
);
istringstream
stst
(
attrval
);
istringstream
stst
(
attrval
);
if
(
attrname
==
"nx"
)
if
(
attrname
==
"nx"
)
{
{
...
@@ -240,8 +240,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
...
@@ -240,8 +240,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
string
attrval
(
XMLString
::
transcode
(
attributes
.
getValue
(
index
))
);
string
attrval
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
(
);
istringstream
stst
(
attrval
);
istringstream
stst
(
attrval
);
if
(
attrname
==
"kpoint"
)
if
(
attrname
==
"kpoint"
)
{
{
...
@@ -302,8 +302,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
...
@@ -302,8 +302,8 @@ void WavefunctionHandler::startElement(const XMLCh* const uri,
unsigned
int
len
=
attributes
.
getLength
();
unsigned
int
len
=
attributes
.
getLength
();
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
for
(
unsigned
int
index
=
0
;
index
<
len
;
index
++
)
{
{
string
attrname
(
XMLString
::
transcode
(
attributes
.
getLocalName
(
index
))
);
string
attrname
=
StrX
(
attributes
.
getLocalName
(
index
)).
localForm
(
);
string
attrval
(
XMLString
::
transcode
(
attributes
.
getValue
(
index
))
);
string
attrval
=
StrX
(
attributes
.
getValue
(
index
)).
localForm
(
);
istringstream
stst
(
attrval
);
istringstream
stst
(
attrval
);
if
(
attrname
==
"nx"
)
if
(
attrname
==
"nx"
)
{
{
...
@@ -338,7 +338,7 @@ void WavefunctionHandler::endElement(const XMLCh* const uri,
...
@@ -338,7 +338,7 @@ void WavefunctionHandler::endElement(const XMLCh* const uri,
{
{
const
Context
&
ctxt
=
wf_
.
context
();
const
Context
&
ctxt
=
wf_
.
context
();
bool
onpe0
=
ctxt
.
onpe0
();
bool
onpe0
=
ctxt
.
onpe0
();
string
locname
(
XMLString
::
transcode
(
localname
)
);
string
locname
=
StrX
(
localname
).
localForm
(
);
//cout << " WavefunctionHandler::endElement " << locname << endl;
//cout << " WavefunctionHandler::endElement " << locname << endl;
if
(
locname
==
"density_matrix"
)
if
(
locname
==
"density_matrix"
)
{
{
...
@@ -495,7 +495,7 @@ void WavefunctionHandler::endSubHandler(const XMLCh* const uri,
...
@@ -495,7 +495,7 @@ void WavefunctionHandler::endSubHandler(const XMLCh* const uri,
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
const
XMLCh
*
const
localname
,
const
XMLCh
*
const
qname
,
const
StructureHandler
*
const
last
)
const
StructureHandler
*
const
last
)
{
{
string
locname
(
XMLString
::
transcode
(
localname
)
);
string
locname
=
StrX
(
localname
).
localForm
(
);
//cout << " WavefunctionHandler::endSubHandler " << locname << endl;
//cout << " WavefunctionHandler::endSubHandler " << locname << endl;
delete
last
;
delete
last
;
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment