From e6bd1956e0f9eb15948b6a7f092a08f27162cad5 Mon Sep 17 00:00:00 2001
From: PeiYong Zhang <peiyongz@apache.org>
Date: Mon, 26 May 2003 21:47:47 +0000
Subject: [PATCH] Use memory manager embedded in rather than the one passed in
 to de-allocate memory.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@175047 13f79535-47bb-0310-9956-ffa450edef68
---
 src/xercesc/util/XMemory.cpp | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/src/xercesc/util/XMemory.cpp b/src/xercesc/util/XMemory.cpp
index 735e07228..0f89e47e8 100644
--- a/src/xercesc/util/XMemory.cpp
+++ b/src/xercesc/util/XMemory.cpp
@@ -116,15 +116,19 @@ void XMemory::operator delete(void* p, MemoryManager* manager)
 {
     assert(manager != 0);
 	
-	if (p != 0)
-	{
-		size_t headerSize = XMLPlatformUtils::alignPointerForNewBlockAllocation(
-											sizeof(MemoryManager*));
+    if (p != 0)
+    {
+        size_t headerSize = XMLPlatformUtils::alignPointerForNewBlockAllocation(sizeof(MemoryManager*));
         void* const block = (char*)p - headerSize;
-		
-		assert(*(MemoryManager**)block == manager);
-		manager->deallocate(block);
-	}
+        assert(*(MemoryManager**)block == manager);
+        /***
+         * NOTE: for compiler which can't properly trace the memory manager used in the 
+         *       placement new, we use the memory manager embedded in the memory rather 
+         *       than the one passed in
+         */ 
+        MemoryManager* pM = *(MemoryManager**)block;
+        pM->deallocate(block);
+    }
 }
 
 #endif
-- 
GitLab