[prev in list] [next in list] [prev in thread] [next in thread] 

List:       xerces-cvs
Subject:    cvs commit: xml-xerces/c/src/xercesc/util ValueVectorOf.hpp ValueVectorOf.c ValueStackOf.hpp ValueSt
From:       knoaman () apache ! org
Date:       2003-05-29 13:26:44
[Download RAW message or body]

knoaman     2003/05/29 06:26:44

  Modified:    c/src/xercesc/util ValueVectorOf.hpp ValueVectorOf.c
                        ValueStackOf.hpp ValueStackOf.c
  Log:
  Fix memory leak when using deprecated dom.
  
  Revision  Changes    Path
  1.7       +5 -0      xml-xerces/c/src/xercesc/util/ValueVectorOf.hpp
  
  Index: ValueVectorOf.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/ValueVectorOf.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ValueVectorOf.hpp	16 May 2003 21:37:00 -0000	1.6
  +++ ValueVectorOf.hpp	29 May 2003 13:26:44 -0000	1.7
  @@ -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 @@
       (
           const unsigned int maxElems
           , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
  +        , const bool toCallDestructor = false
       );
       ValueVectorOf(const ValueVectorOf<TElem>& toCopy);
       ~ValueVectorOf();
  @@ -174,6 +178,7 @@
       //      The list of elements, which is dynamically allocated to the needed
       //      size.
       // -----------------------------------------------------------------------
  +    bool            fCallDestructor;
       unsigned int    fCurCount;
       unsigned int    fMaxCount;
       TElem*          fElemList;
  
  
  
  1.7       +15 -3     xml-xerces/c/src/xercesc/util/ValueVectorOf.c
  
  Index: ValueVectorOf.c
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/ValueVectorOf.c,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ValueVectorOf.c	20 May 2003 21:06:30 -0000	1.6
  +++ ValueVectorOf.c	29 May 2003 13:26:44 -0000	1.7
  @@ -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 @@
   // ---------------------------------------------------------------------------
   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 @@
   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 @@
       (
           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;
   }
   
  
  
  
  1.6       +5 -1      xml-xerces/c/src/xercesc/util/ValueStackOf.hpp
  
  Index: ValueStackOf.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/ValueStackOf.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ValueStackOf.hpp	16 May 2003 06:01:52 -0000	1.5
  +++ ValueStackOf.hpp	29 May 2003 13:26:44 -0000	1.6
  @@ -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 @@
       ValueStackOf
       (
             const unsigned int fInitCapacity
  -		  , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
  +          , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
  +          , const bool toCallDestructor = false
       );
       ~ValueStackOf();
   
  
  
  
  1.4       +6 -2      xml-xerces/c/src/xercesc/util/ValueStackOf.c
  
  Index: ValueStackOf.c
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/util/ValueStackOf.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ValueStackOf.c	16 May 2003 06:01:52 -0000	1.3
  +++ ValueStackOf.c	29 May 2003 13:26:44 -0000	1.4
  @@ -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 @@
   // ---------------------------------------------------------------------------
   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)
   {
   }
   
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic