dbertoni    00/07/05 15:17:08

  Modified:    c/src/XercesPlatformSupport XercesTextOutputStream.cpp
  Log:
  Updated buffer management code.
  
  Revision  Changes    Path
  1.6       +21 -3     
xml-xalan/c/src/XercesPlatformSupport/XercesTextOutputStream.cpp
  
  Index: XercesTextOutputStream.cpp
  ===================================================================
  RCS file: 
/home/cvs/xml-xalan/c/src/XercesPlatformSupport/XercesTextOutputStream.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XercesTextOutputStream.cpp        2000/06/28 17:52:36     1.5
  +++ XercesTextOutputStream.cpp        2000/07/05 22:17:07     1.6
  @@ -70,8 +70,9 @@
   
   XercesTextOutputStream::XercesTextOutputStream(BufferType::size_type 
theBufferSize) :
        m_buffer(),
  -     m_bufferSize(theBufferSize)
  +     m_bufferSize(0)
   {
  +     setBufferSize(theBufferSize);
   }
   
   
  @@ -204,11 +205,28 @@
   void
   XercesTextOutputStream::setBufferSize(BufferType::size_type          
theBufferSize)
   {
  +     flushBuffer();
  +
        m_bufferSize = theBufferSize;
   
  -     if (m_buffer.size() > m_bufferSize)
  +     if (m_buffer.size() < m_bufferSize)
        {
  -             flushBuffer();
  +             // Enlarge the buffer...
  +             m_buffer.reserve(theBufferSize);
  +     }
  +     else if (m_buffer.size() > m_bufferSize)
  +     {
  +             // Shrink the buffer.
  +
  +             // Create a temp buffer and make it
  +             // the correct size.
  +             BufferType      temp;
  +             
  +             temp.reserve(theBufferSize);
  +             
  +             // Swap temp with m_buffer so that
  +             // m_buffer is now the correct size.
  +             temp.swap(m_buffer);
        }
   }
   
  
  
  

Reply via email to