CSJ2K.j2k.util.ISRandomAccessIO.growBuffer C# (CSharp) Method

growBuffer() private method

Grows the cache buffer by 'inc', upto a maximum of 'maxsize'. The buffer size will be increased by at least one byte, if no exception is thrown.
If the maximum cache size is reached or if not /// enough memory is available to grow the buffer. /// ///
private growBuffer ( ) : void
return void
        private void growBuffer()
        {
            byte[] newbuf;
            int effinc; // effective increment

            effinc = inc;
            if (buf.Length + effinc > maxsize)
                effinc = maxsize - buf.Length;
            if (effinc <= 0)
            {
                throw new System.IO.IOException("Reached maximum cache size (" + maxsize + ")");
            }
            try
            {
                newbuf = new byte[buf.Length + inc];
            }
            catch (System.OutOfMemoryException e)
            {
                throw new System.IO.IOException("Out of memory to cache input data");
            }
            Array.Copy(buf, 0, newbuf, 0, len);
            buf = newbuf;
        }