diff --git a/src/xercesc/framework/XMLAttDef.cpp b/src/xercesc/framework/XMLAttDef.cpp index 9b1298314fe14f698c3c79cdf3fc9614c6351345..fd0af0cba995b328513f72ac231f3ee29828dd42 100644 --- a/src/xercesc/framework/XMLAttDef.cpp +++ b/src/xercesc/framework/XMLAttDef.cpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,10 +62,9 @@ // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- +#include <xercesc/framework/XMLAttDef.hpp> #include <xercesc/util/ArrayIndexOutOfBoundsException.hpp> -#include <xercesc/util/XMLUniDefs.hpp> #include <xercesc/util/XMLUni.hpp> -#include <xercesc/framework/XMLAttDef.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -156,13 +155,13 @@ XMLAttDef::XMLAttDef(const XMLAttDef::AttTypes type , const XMLAttDef::DefAttTypes defType) : fDefaultType(defType) - , fEnumeration(0) - , fId(XMLAttDef::fgInvalidAttrId) - , fProvided(false) , fType(type) - , fValue(0) , fCreateReason(XMLAttDef::NoReason) + , fProvided(false) , fExternalAttribute(false) + , fId(XMLAttDef::fgInvalidAttrId) + , fValue(0) + , fEnumeration(0) { } @@ -172,20 +171,18 @@ XMLAttDef::XMLAttDef(const XMLCh* const attrValue , const XMLCh* const enumValues) : fDefaultType(defType) - , fEnumeration(0) - , fId(XMLAttDef::fgInvalidAttrId) - , fProvided(false) , fType(type) - , fValue(0) , fCreateReason(XMLAttDef::NoReason) + , fProvided(false) , fExternalAttribute(false) + , fId(XMLAttDef::fgInvalidAttrId) + , fValue(XMLString::replicate(attrValue)) + , fEnumeration(0) { try { - fValue = XMLString::replicate(attrValue); fEnumeration = XMLString::replicate(enumValues); } - catch(...) { cleanUp(); @@ -198,8 +195,11 @@ XMLAttDef::XMLAttDef(const XMLCh* const attrValue // --------------------------------------------------------------------------- void XMLAttDef::cleanUp() { - delete [] fEnumeration; - delete [] fValue; + if (fEnumeration) + XMLString::release(&fEnumeration); + + if (fValue) + XMLString::release(&fValue); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/framework/XMLAttDef.hpp b/src/xercesc/framework/XMLAttDef.hpp index 03c046fd359efd47b0e80120b785e2c3e9220314..2070b2dd6919101da0a02c9b4a80d80d3dff49e7 100644 --- a/src/xercesc/framework/XMLAttDef.hpp +++ b/src/xercesc/framework/XMLAttDef.hpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2001 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.7 2003/04/21 20:46:01 knoaman + * Use XMLString::release to prepare for configurable memory manager. + * * Revision 1.6 2003/03/07 18:08:10 tng * Return a reference instead of void for operator= * @@ -557,17 +560,16 @@ private : // This flag indicates whether or not the attribute was declared externally. // ----------------------------------------------------------------------- DefAttTypes fDefaultType; - XMLCh* fEnumeration; - unsigned int fId; - bool fProvided; AttTypes fType; - XMLCh* fValue; CreateReasons fCreateReason; + bool fProvided; bool fExternalAttribute; + unsigned int fId; + XMLCh* fValue; + XMLCh* fEnumeration; }; - // --------------------------------------------------------------------------- // Getter methods // --------------------------------------------------------------------------- @@ -622,14 +624,10 @@ inline void XMLAttDef::setDefaultType(const XMLAttDef::DefAttTypes newValue) inline void XMLAttDef::setEnumeration(const XMLCh* const newValue) { - delete [] fEnumeration; - - if (newValue) { - fEnumeration = XMLString::replicate(newValue); - } - else { - fEnumeration = 0; - } + if (fEnumeration) + XMLString::release(&fEnumeration); + + fEnumeration = XMLString::replicate(newValue); } inline void XMLAttDef::setId(const unsigned int newId) @@ -649,7 +647,9 @@ inline void XMLAttDef::setType(const XMLAttDef::AttTypes newValue) inline void XMLAttDef::setValue(const XMLCh* const newValue) { - delete [] fValue; + if (fValue) + XMLString::release(&fValue); + fValue = XMLString::replicate(newValue); } diff --git a/src/xercesc/framework/XMLEntityDecl.cpp b/src/xercesc/framework/XMLEntityDecl.cpp index 49afc97ae356f5cbf118ac1d65dd3890678e66b2..6a042823c88972242df1fb1abf38e205affc2783 100644 --- a/src/xercesc/framework/XMLEntityDecl.cpp +++ b/src/xercesc/framework/XMLEntityDecl.cpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2000 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -62,10 +62,9 @@ // --------------------------------------------------------------------------- // Includes // --------------------------------------------------------------------------- -#include <xercesc/util/XMLUniDefs.hpp> -#include <xercesc/util/XMLUni.hpp> -#include <xercesc/util/XMLString.hpp> #include <xercesc/framework/XMLEntityDecl.hpp> +#include <xercesc/util/XMLUniDefs.hpp> + XERCES_CPP_NAMESPACE_BEGIN @@ -74,46 +73,45 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- XMLEntityDecl::XMLEntityDecl() : - fName(0) + fId(0) + , fValueLen(0) + , fValue(0) + , fName(0) , fNotationName(0) , fPublicId(0) , fSystemId(0) , fBaseURI(0) - , fValue(0) - , fValueLen(0) { } XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName) : - fName(0) + fId(0) + , fValueLen(0) + , fValue(0) + , fName(XMLString::replicate(entName)) , fNotationName(0) , fPublicId(0) , fSystemId(0) , fBaseURI(0) - , fValue(0) - , fValueLen(0) { - fName = XMLString::replicate(entName); } XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName , const XMLCh* const value) : - fName(0) + fId(0) + , fValueLen(XMLString::stringLen(value)) + , fValue(XMLString::replicate(value)) + , fName(0) , fNotationName(0) , fPublicId(0) , fSystemId(0) , fBaseURI(0) - , fValue(0) - , fValueLen(0) { try { fName = XMLString::replicate(entName); - fValue = XMLString::replicate(value); - fValueLen = XMLString::stringLen(value); } - catch(...) { cleanUp(); @@ -122,23 +120,21 @@ XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName XMLEntityDecl::XMLEntityDecl(const XMLCh* const entName , const XMLCh value) : - fName(0) + fId(0) + , fValueLen(1) + , fValue(0) + , fName(XMLString::replicate(entName)) , fNotationName(0) , fPublicId(0) , fSystemId(0) , fBaseURI(0) - , fValue(0) - , fValueLen(0) { try { - fValue = new XMLCh[2]; - fValue[0] = value; - fValue[1] = chNull; - fValueLen = 1; - fName = XMLString::replicate(entName); + XMLCh dummy[2] = { chNull, chNull }; + dummy[0] = value; + fValue = XMLString::replicate(dummy); } - catch(...) { cleanUp(); @@ -157,8 +153,9 @@ XMLEntityDecl::~XMLEntityDecl() void XMLEntityDecl::setName(const XMLCh* const entName) { // Clean up the current name stuff - delete [] fName; - fName = 0; + if (fName) + XMLString::release(&fName); + fName = XMLString::replicate(entName); } @@ -168,12 +165,12 @@ void XMLEntityDecl::setName(const XMLCh* const entName) // --------------------------------------------------------------------------- void XMLEntityDecl::cleanUp() { - delete [] fName; - delete [] fNotationName; - delete [] fValue; - delete [] fPublicId; - delete [] fSystemId; - delete [] fBaseURI; + XMLString::release(&fName); + XMLString::release(&fNotationName); + XMLString::release(&fValue); + XMLString::release(&fPublicId); + XMLString::release(&fSystemId); + XMLString::release(&fBaseURI); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/framework/XMLEntityDecl.hpp b/src/xercesc/framework/XMLEntityDecl.hpp index 4923c613691b8f356fce097e676b8e339ba98168..9511167cb7554560d177926936b17c434fa79aee 100644 --- a/src/xercesc/framework/XMLEntityDecl.hpp +++ b/src/xercesc/framework/XMLEntityDecl.hpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2000 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/04/21 20:46:01 knoaman + * Use XMLString::release to prepare for configurable memory manager. + * * Revision 1.4 2003/03/07 18:08:10 tng * Return a reference instead of void for operator= * @@ -413,12 +416,12 @@ private : // is the URI where it is declared (NOT referenced). // ----------------------------------------------------------------------- unsigned int fId; - XMLCh* fName; + unsigned int fValueLen; + XMLCh* fValue; + XMLCh* fName; XMLCh* fNotationName; XMLCh* fPublicId; XMLCh* fSystemId; - XMLCh* fValue; - unsigned int fValueLen; XMLCh* fBaseURI; }; @@ -489,31 +492,41 @@ inline void XMLEntityDecl::setId(const unsigned int newId) inline void XMLEntityDecl::setNotationName(const XMLCh* const newName) { - delete [] fNotationName; + if (fNotationName) + XMLString::release(&fNotationName); + fNotationName = XMLString::replicate(newName); } inline void XMLEntityDecl::setPublicId(const XMLCh* const newId) { - delete [] fPublicId; + if (fPublicId) + XMLString::release(&fPublicId); + fPublicId = XMLString::replicate(newId); } inline void XMLEntityDecl::setSystemId(const XMLCh* const newId) { - delete [] fSystemId; + if (fSystemId) + XMLString::release(&fSystemId); + fSystemId = XMLString::replicate(newId); } inline void XMLEntityDecl::setBaseURI(const XMLCh* const newId) { - delete [] fBaseURI; + if (fBaseURI) + XMLString::release(&fBaseURI); + fBaseURI = XMLString::replicate(newId); } inline void XMLEntityDecl::setValue(const XMLCh* const newValue) { - delete [] fValue; + if (fValue) + XMLString::release(&fValue); + fValue = XMLString::replicate(newValue); fValueLen = XMLString::stringLen(newValue); } diff --git a/src/xercesc/framework/XMLNotationDecl.cpp b/src/xercesc/framework/XMLNotationDecl.cpp index 41114093ee00729196560b2d353baf7014564375..1d0baf98af3258fac177ae90d3565ed3c8b9a23e 100644 --- a/src/xercesc/framework/XMLNotationDecl.cpp +++ b/src/xercesc/framework/XMLNotationDecl.cpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2000 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,9 @@ /** * $Log$ + * Revision 1.4 2003/04/21 20:46:01 knoaman + * Use XMLString::release to prepare for configurable memory manager. + * * Revision 1.3 2002/11/04 15:00:21 tng * C++ Namespace Support. * @@ -89,7 +92,8 @@ XERCES_CPP_NAMESPACE_BEGIN // --------------------------------------------------------------------------- XMLNotationDecl::XMLNotationDecl() : - fName(0) + fId(0) + , fName(0) , fPublicId(0) , fSystemId(0) , fBaseURI(0) @@ -100,7 +104,8 @@ XMLNotationDecl::XMLNotationDecl( const XMLCh* const notName , const XMLCh* const pubId , const XMLCh* const sysId , const XMLCh* const baseURI) : - fName(0) + fId(0) + , fName(XMLString::replicate(notName)) , fPublicId(0) , fSystemId(0) , fBaseURI(0) @@ -110,9 +115,7 @@ XMLNotationDecl::XMLNotationDecl( const XMLCh* const notName fPublicId = XMLString::replicate(pubId); fSystemId = XMLString::replicate(sysId); fBaseURI = XMLString::replicate(baseURI); - setName(notName); } - catch(...) { cleanUp(); @@ -131,8 +134,9 @@ XMLNotationDecl::~XMLNotationDecl() void XMLNotationDecl::setName(const XMLCh* const notName) { // Clean up the current name stuff and replicate the passed name - delete [] fName; - fName = 0; + if (fName) + XMLString::release(&fName); + fName = XMLString::replicate(notName); } @@ -143,10 +147,10 @@ void XMLNotationDecl::setName(const XMLCh* const notName) // --------------------------------------------------------------------------- void XMLNotationDecl::cleanUp() { - delete [] fName; - delete [] fPublicId; - delete [] fSystemId; - delete [] fBaseURI; + XMLString::release(&fName); + XMLString::release(&fPublicId); + XMLString::release(&fSystemId); + XMLString::release(&fBaseURI); } XERCES_CPP_NAMESPACE_END diff --git a/src/xercesc/framework/XMLNotationDecl.hpp b/src/xercesc/framework/XMLNotationDecl.hpp index 553e1aba64cf1bec4025629ca0cbdf4e964f2b3e..3e676952d4900819a7f977716867bd69c8c352a5 100644 --- a/src/xercesc/framework/XMLNotationDecl.hpp +++ b/src/xercesc/framework/XMLNotationDecl.hpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2000 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/04/21 20:46:01 knoaman + * Use XMLString::release to prepare for configurable memory manager. + * * Revision 1.4 2003/03/07 18:08:10 tng * Return a reference instead of void for operator= * @@ -93,7 +96,6 @@ #if !defined(XMLNOTATIONDECL_HPP) #define XMLNOTATIONDECL_HPP -#include <xercesc/util/XercesDefs.hpp> #include <xercesc/util/XMLString.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -241,19 +243,25 @@ inline void XMLNotationDecl::setId(const unsigned int newId) inline void XMLNotationDecl::setPublicId(const XMLCh* const newId) { - delete [] fPublicId; + if (fPublicId) + XMLString::release(&fPublicId); + fPublicId = XMLString::replicate(newId); } inline void XMLNotationDecl::setSystemId(const XMLCh* const newId) { - delete [] fSystemId; + if (fSystemId) + XMLString::release(&fSystemId); + fSystemId = XMLString::replicate(newId); } inline void XMLNotationDecl::setBaseURI(const XMLCh* const newId) { - delete [] fBaseURI; + if (fBaseURI) + XMLString::release(&fBaseURI); + fBaseURI = XMLString::replicate(newId); } diff --git a/src/xercesc/framework/XMLRefInfo.hpp b/src/xercesc/framework/XMLRefInfo.hpp index 8889975eac6430da6c31811033b44b41eb93c0a4..1c560a9fe941bb1b9949da74d738603c93fab0b7 100644 --- a/src/xercesc/framework/XMLRefInfo.hpp +++ b/src/xercesc/framework/XMLRefInfo.hpp @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 1999-2000 The Apache Software Foundation. All rights + * Copyright (c) 1999-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.5 2003/04/21 20:46:01 knoaman + * Use XMLString::release to prepare for configurable memory manager. + * * Revision 1.4 2003/03/07 18:08:10 tng * Return a reference instead of void for operator= * @@ -173,8 +176,8 @@ private : // a declared ID. // ----------------------------------------------------------------------- bool fDeclared; - XMLCh* fRefName; bool fUsed; + XMLCh* fRefName; }; @@ -185,14 +188,14 @@ inline XMLRefInfo::XMLRefInfo( const XMLCh* const refName , const bool declared , const bool used) : fDeclared(declared) - , fRefName(XMLString::replicate(refName)) , fUsed(used) + , fRefName(XMLString::replicate(refName)) { } inline XMLRefInfo::~XMLRefInfo() { - delete [] fRefName; + XMLString::release(&fRefName); }