Skip to content
Snippets Groups Projects
Commit 59c78f11 authored by Khaled Noaman's avatar Khaled Noaman
Browse files

Fix memory leak when using deprecated dom.

git-svn-id: https://svn.apache.org/repos/asf/xerces/c/trunk@175058 13f79535-47bb-0310-9956-ffa450edef68
parent a26eb47e
No related branches found
No related tags found
No related merge requests found
......@@ -56,6 +56,9 @@
/**
* $Log$
* Revision 1.4 2003/05/29 13:26:44 knoaman
* Fix memory leak when using deprecated dom.
*
* Revision 1.3 2003/05/16 06:01:52 knoaman
* Partial implementation of the configurable memory manager.
*
......@@ -97,9 +100,10 @@ XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
template <class TElem>
ValueStackOf<TElem>::ValueStackOf(const unsigned int fInitCapacity,
MemoryManager* const manager) :
MemoryManager* const manager,
const bool toCallDestructor) :
fVector(fInitCapacity, manager)
fVector(fInitCapacity, manager, toCallDestructor)
{
}
......
......@@ -56,6 +56,9 @@
/*
* $Log$
* Revision 1.6 2003/05/29 13:26:44 knoaman
* Fix memory leak when using deprecated dom.
*
* Revision 1.5 2003/05/16 06:01:52 knoaman
* Partial implementation of the configurable memory manager.
*
......@@ -114,7 +117,8 @@ public :
ValueStackOf
(
const unsigned int fInitCapacity
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, const bool toCallDestructor = false
);
~ValueStackOf();
......
......@@ -56,6 +56,9 @@
/**
* $Log$
* Revision 1.7 2003/05/29 13:26:44 knoaman
* Fix memory leak when using deprecated dom.
*
* Revision 1.6 2003/05/20 21:06:30 knoaman
* Set values to 0.
*
......@@ -112,9 +115,11 @@ XERCES_CPP_NAMESPACE_BEGIN
// ---------------------------------------------------------------------------
template <class TElem>
ValueVectorOf<TElem>::ValueVectorOf(const unsigned int maxElems,
MemoryManager* const manager) :
MemoryManager* const manager,
const bool toCallDestructor) :
fCurCount(0)
fCallDestructor(toCallDestructor)
, fCurCount(0)
, fMaxCount(maxElems)
, fElemList(0)
, fMemoryManager(manager)
......@@ -130,7 +135,8 @@ ValueVectorOf<TElem>::ValueVectorOf(const unsigned int maxElems,
template <class TElem>
ValueVectorOf<TElem>::ValueVectorOf(const ValueVectorOf<TElem>& toCopy) :
fCurCount(toCopy.fCurCount)
fCallDestructor(toCopy.fCallDestructor)
, fCurCount(toCopy.fCurCount)
, fMaxCount(toCopy.fMaxCount)
, fElemList(0)
, fMemoryManager(toCopy.fMemoryManager)
......@@ -139,12 +145,18 @@ ValueVectorOf<TElem>::ValueVectorOf(const ValueVectorOf<TElem>& toCopy) :
(
fMaxCount * sizeof(TElem)
); //new TElem[fMaxCount];
memset(fElemList, 0, fMaxCount * sizeof(TElem));
for (unsigned int index = 0; index < fCurCount; index++)
fElemList[index] = toCopy.fElemList[index];
}
template <class TElem> ValueVectorOf<TElem>::~ValueVectorOf()
{
if (fCallDestructor) {
for (int index= fMaxCount - 1; index >= 0; index--)
fElemList[index].~TElem();
}
fMemoryManager->deallocate(fElemList); //delete [] fElemList;
}
......
......@@ -56,6 +56,9 @@
/*
* $Log$
* Revision 1.7 2003/05/29 13:26:44 knoaman
* Fix memory leak when using deprecated dom.
*
* Revision 1.6 2003/05/16 21:37:00 knoaman
* Memory manager implementation: Modify constructors to pass in the memory manager.
*
......@@ -120,6 +123,7 @@ public :
(
const unsigned int maxElems
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, const bool toCallDestructor = false
);
ValueVectorOf(const ValueVectorOf<TElem>& toCopy);
~ValueVectorOf();
......@@ -174,6 +178,7 @@ private:
// The list of elements, which is dynamically allocated to the needed
// size.
// -----------------------------------------------------------------------
bool fCallDestructor;
unsigned int fCurCount;
unsigned int fMaxCount;
TElem* fElemList;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment