leosutic    02/03/06 00:17:17

  Modified:    src/java/org/apache/avalon/excalibur/collections
                        VariableSizeBuffer.java
  Log:
  Fixed bug that resized the buffer incorrectly.
  
  Revision  Changes    Path
  1.5       +12 -3     
jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/collections/VariableSizeBuffer.java
  
  Index: VariableSizeBuffer.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-avalon-excalibur/src/java/org/apache/avalon/excalibur/collections/VariableSizeBuffer.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- VariableSizeBuffer.java   26 Feb 2002 02:07:50 -0000      1.4
  +++ VariableSizeBuffer.java   6 Mar 2002 08:17:17 -0000       1.5
  @@ -14,7 +14,7 @@
    *
    * @author  <a href="[EMAIL PROTECTED]">Federico Barbieri</a>
    * @author  <a href="[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.4 $ $Date: 2002/02/26 02:07:50 $
  + * @version CVS $Revision: 1.5 $ $Date: 2002/03/06 08:17:17 $
    * @since 4.0
    */
   public final class VariableSizeBuffer implements Buffer
  @@ -88,13 +88,22 @@
           {
               Object[] tmp = new Object[ ( (m_buffer.length - 1) * 2) + 1 ];
   
  -            for ( int i = 0; i < m_buffer.length; i++ )
  +            int j = 0;
  +            for ( int i = m_head; i != m_tail; )
               {
  -                tmp[i] = m_buffer[i];
  +                tmp[j] = m_buffer[i];
                   m_buffer[i] = null;
  +
  +                j++;
  +                i++;
  +                if (i == m_buffer.length) {
  +                    i = 0;
  +                }
               }
   
               m_buffer = tmp;
  +            m_head = 0;
  +            m_tail = j;
           }
   
           m_buffer[ m_tail ] = o;
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to