You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by kn...@apache.org on 2003/05/16 17:32:12 UTC
cvs commit: xml-xerces/c/samples/StdInParse StdInParse.cpp
knoaman 2003/05/16 08:32:12
Modified: c/samples/StdInParse StdInParse.cpp
Log:
Change scope of 'src' so that it's deallocated properly.
Revision Changes Path
1.14 +35 -29 xml-xerces/c/samples/StdInParse/StdInParse.cpp
Index: StdInParse.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/samples/StdInParse/StdInParse.cpp,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -r1.13 -r1.14
--- StdInParse.cpp 1 Feb 2002 22:41:37 -0000 1.13
+++ StdInParse.cpp 16 May 2003 15:32:12 -0000 1.14
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.14 2003/05/16 15:32:12 knoaman
+ * Change scope of 'src' so that it's deallocated properly.
+ *
* Revision 1.13 2002/02/01 22:41:37 peiyongz
* sane_include
*
@@ -253,38 +256,41 @@
parser->setDocumentHandler(&handler);
parser->setErrorHandler(&handler);
- //
- // Kick off the parse and catch any exceptions. Create a standard
- // input input source and tell the parser to parse from that.
- //
unsigned long duration;
int errorCount = 0;
- StdInInputSource src;
- try
- {
- const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
- parser->parse(src);
- const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
- duration = endMillis - startMillis;
- errorCount = parser->getErrorCount();
- }
-
- catch (const XMLException& e)
+ // create a faux scope so that 'src' destructor is called before
+ // XMLPlatformUtils::Terminate
{
- cerr << "\nError during parsing: \n"
- << StrX(e.getMessage())
- << "\n" << endl;
- XMLPlatformUtils::Terminate();
- return 4;
- }
-
- // Print out the stats that we collected and time taken
- if (!errorCount) {
- cout << StrX(src.getSystemId()) << ": " << duration << " ms ("
- << handler.getElementCount() << " elems, "
- << handler.getAttrCount() << " attrs, "
- << handler.getSpaceCount() << " spaces, "
- << handler.getCharacterCount() << " chars)" << endl;
+ //
+ // Kick off the parse and catch any exceptions. Create a standard
+ // input input source and tell the parser to parse from that.
+ //
+ StdInInputSource src;
+ try
+ {
+ const unsigned long startMillis = XMLPlatformUtils::getCurrentMillis();
+ parser->parse(src);
+ const unsigned long endMillis = XMLPlatformUtils::getCurrentMillis();
+ duration = endMillis - startMillis;
+ errorCount = parser->getErrorCount();
+ }
+ catch (const XMLException& e)
+ {
+ cerr << "\nError during parsing: \n"
+ << StrX(e.getMessage())
+ << "\n" << endl;
+ errorCount = 1;
+ return 4;
+ }
+
+ // Print out the stats that we collected and time taken
+ if (!errorCount) {
+ cout << StrX(src.getSystemId()) << ": " << duration << " ms ("
+ << handler.getElementCount() << " elems, "
+ << handler.getAttrCount() << " attrs, "
+ << handler.getSpaceCount() << " spaces, "
+ << handler.getCharacterCount() << " chars)" << endl;
+ }
}
//
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org