You are viewing a plain text version of this content. The canonical link for it is here.
Posted to c-dev@xerces.apache.org by Miroslaw Dobrzanski-Neumann <mn...@mosaic-ag.com> on 2000/11/02 18:31:55 UTC
DOMParser
Hi,
DOMParser takes the validator and than deletes it in the destructor. Under
Windows You have the well known problemms of freeing foreign memory. The
following patch let the Parser use an validator but it will not be freed if
not allocated in the parser. So each party is responsible for own resources.
You must also change the documentation to reflect the user responsibility for
freeing the validator. (I prefer not to depend on the way third party
components are created)
--- DOMParser.org.hpp Thu Nov 2 17:37:32 2000
+++ DOMParser.hpp Thu Nov 2 17:56:54 2000
@@ -1270,6 +1270,7 @@
bool fParseInProgress;
XMLScanner* fScanner;
XMLValidator* fValidator;
+ XMLValidator* fOwnValidator;
bool fWithinElement;
DocumentTypeImpl* fDocumentType;
DocTypeHandler* fOldDocTypeHandler;
--- DOMParser.org.cpp Thu Nov 2 17:37:24 2000
+++ DOMParser.cpp Thu Nov 2 18:00:46 2000
@@ -105,11 +105,14 @@
, fScanner(0)
, fOldDocTypeHandler(0)
, fValidator(valToAdopt)
+, fOwnValidator(0)
{
// Create the validator if one was not provided
- if (!fValidator)
- fValidator = new DTDValidator;
+ if (!fValidator) {
+ fOwnValidator = new DTDValidator;
+ fValidator = fOwnValidator;
+ }
//If the user already registered the doctypehandler then chain it
fOldDocTypeHandler = ((DTDValidator*)fValidator)->getDocTypeHandler();
@@ -134,7 +137,8 @@
{
delete fNodeStack;
delete fScanner;
- delete fValidator;
+ if (fOwnValidator)
+ delete fOwnValidator;
}
regards
--
Miroslaw Dobrzanski-Neumann
MOSAIC SOFTWARE AG
Base Development and Research
Tel +49-2225-882-291
Fax +49-2225-882-201
E-mail: mne@mosaic-ag.com