From a447ff36c5d821fbdc4e940af31c078f58444eca Mon Sep 17 00:00:00 2001 From: James David Berry <jberry@apache.org> Date: Wed, 27 Aug 2003 16:41:56 +0000 Subject: [PATCH] Add new static global that always points to array-allocating memory manager git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@175177 13f79535-47bb-0310-9956-ffa450edef68 --- src/xercesc/util/PlatformUtils.cpp | 20 ++++++++++++------- src/xercesc/util/PlatformUtils.hpp | 10 ++++++++++ .../Platforms/MacOS/MacOSPlatformUtils.hpp | 8 ++++---- .../MacOSUnicodeConverter.cpp | 7 ++----- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/xercesc/util/PlatformUtils.cpp b/src/xercesc/util/PlatformUtils.cpp index 3599ca3fc..f8de39d68 100644 --- a/src/xercesc/util/PlatformUtils.cpp +++ b/src/xercesc/util/PlatformUtils.cpp @@ -56,6 +56,9 @@ /* * $Log$ + * Revision 1.11 2003/08/27 16:41:56 jberry + * Add new static global that always points to array-allocating memory manager + * * Revision 1.10 2003/05/18 14:02:05 knoaman * Memory manager implementation: pass per instance manager. * @@ -169,6 +172,7 @@ #include <xercesc/util/XMLRegisterCleanup.hpp> #include <xercesc/util/DefaultPanicHandler.hpp> #include <xercesc/internal/MemoryManagerImpl.hpp> +#include <xercesc/internal/MemoryManagerArrayImpl.hpp> #include <limits.h> @@ -203,12 +207,14 @@ XMLMutex* gXMLCleanupListMutex = 0; // --------------------------------------------------------------------------- // XMLPlatformUtils: Static Data Members // --------------------------------------------------------------------------- -XMLNetAccessor* XMLPlatformUtils::fgNetAccessor = 0; -XMLTransService* XMLPlatformUtils::fgTransService = 0; -PanicHandler* XMLPlatformUtils::fgUserPanicHandler = 0; -PanicHandler* XMLPlatformUtils::fgDefaultPanicHandler = 0; -MemoryManager* XMLPlatformUtils::fgMemoryManager = 0; -bool XMLPlatformUtils::fgMemMgrAdopted = true; +XMLNetAccessor* XMLPlatformUtils::fgNetAccessor = 0; +XMLTransService* XMLPlatformUtils::fgTransService = 0; +PanicHandler* XMLPlatformUtils::fgUserPanicHandler = 0; +PanicHandler* XMLPlatformUtils::fgDefaultPanicHandler = 0; +MemoryManager* XMLPlatformUtils::fgMemoryManager = 0; +MemoryManagerArrayImpl gArrayMemoryManager; +MemoryManager* XMLPlatformUtils::fgArrayMemoryManager = &gArrayMemoryManager; +bool XMLPlatformUtils::fgMemMgrAdopted = true; // --------------------------------------------------------------------------- // XMLPlatformUtils: Init/term methods @@ -243,7 +249,7 @@ void XMLPlatformUtils::Initialize(const char* const locale fgMemoryManager = new MemoryManagerImpl(); } } - + // // Make sure we haven't already been initialized. Note that this is not // thread safe and is not intended for that. Its more for those COM diff --git a/src/xercesc/util/PlatformUtils.hpp b/src/xercesc/util/PlatformUtils.hpp index 1861b8556..923683e90 100644 --- a/src/xercesc/util/PlatformUtils.hpp +++ b/src/xercesc/util/PlatformUtils.hpp @@ -152,6 +152,16 @@ public : */ static MemoryManager* fgMemoryManager; + /** The array-allocating memory manager + * + * This memory manager always allocates memory by calling the + * global new[] operator. It may be used to allocate memory + * where such memory needs to be deletable by calling delete []. + * Since this allocator is always guaranteed to do the same thing + * there is no reason, nor facility, to override it. + */ + static MemoryManager* fgArrayMemoryManager; + //@} diff --git a/src/xercesc/util/Platforms/MacOS/MacOSPlatformUtils.hpp b/src/xercesc/util/Platforms/MacOS/MacOSPlatformUtils.hpp index d2d9e82ee..21a392d3a 100644 --- a/src/xercesc/util/Platforms/MacOS/MacOSPlatformUtils.hpp +++ b/src/xercesc/util/Platforms/MacOS/MacOSPlatformUtils.hpp @@ -98,18 +98,18 @@ XMLUTIL_EXPORT XMLMacAbstractFile* XMLMakeMacFile(void); // Convert fom FSRef/FSSpec to a Unicode character string path. // Note that you'll need to delete [] that string after you're done with it! XMLUTIL_EXPORT XMLCh* XMLCreateFullPathFromFSRef(const FSRef& startingRef, - MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); + MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager); XMLUTIL_EXPORT XMLCh* XMLCreateFullPathFromFSSpec(const FSSpec& startingSpec, - MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); + MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager); // Convert from path to FSRef/FSSpec // You retain ownership of the pathName. // Note: in the general case, these routines will fail if the specified file // does not exist when the routine is called. XMLUTIL_EXPORT bool XMLParsePathToFSRef(const XMLCh* const pathName, FSRef& ref, - MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); + MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager); XMLUTIL_EXPORT bool XMLParsePathToFSSpec(const XMLCh* const pathName, FSSpec& spec, - MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager); + MemoryManager* const manager = XMLPlatformUtils::fgArrayMemoryManager); // These routines copy characters between their representation in the Unicode Converter // and the representation used by XMLCh. Until a recent change in Xerces, these were diff --git a/src/xercesc/util/Transcoders/MacOSUnicodeConverter/MacOSUnicodeConverter.cpp b/src/xercesc/util/Transcoders/MacOSUnicodeConverter/MacOSUnicodeConverter.cpp index 9a6939db5..3586ba493 100644 --- a/src/xercesc/util/Transcoders/MacOSUnicodeConverter/MacOSUnicodeConverter.cpp +++ b/src/xercesc/util/Transcoders/MacOSUnicodeConverter/MacOSUnicodeConverter.cpp @@ -98,7 +98,6 @@ #include <xercesc/util/PlatformUtils.hpp> #include <xercesc/util/Janitor.hpp> #include <xercesc/util/Platforms/MacOS/MacOSPlatformUtils.hpp> -#include <xercesc/internal/MemoryManagerArrayImpl.hpp> XERCES_CPP_NAMESPACE_BEGIN @@ -1008,8 +1007,7 @@ MacOSLCPTranscoder::transcode(const XMLCh* const srcText) { // Transcode using a memory manager that allocates // memory using new[]. - MemoryManagerArrayImpl allocator; - return transcode(srcText, &allocator); + return transcode(srcText, XMLPlatformUtils::fgArrayMemoryManager); } @@ -1129,8 +1127,7 @@ MacOSLCPTranscoder::transcode(const char* const srcText) { // Transcode using a memory manager that allocates // memory using new[]. - MemoryManagerArrayImpl allocator; - return transcode(srcText, &allocator); + return transcode(srcText, XMLPlatformUtils::fgArrayMemoryManager); } -- GitLab