DBreeze.Storage.MemoryStorage.Resize C# (CSharp) Method

Resize() private method

private Resize ( int upTo ) : void
upTo int
return void
        private void Resize(int upTo)
        {
            if (upTo <= 0)
                return;

            byte[] _nf = null;
            int x=1;

            switch (_expandStrategy)
            {
                case eMemoryExpandStartegy.MULTIPLY_CAPACITY_BY_2:

                    if (_capacity * 2 < upTo)
                    {
                        x = (int)Math.Ceiling((double)upTo / ((double) 2 * _capacity));
                    }
                    _capacity = _capacity * 2 * x;

                    break;
                case eMemoryExpandStartegy.FIXED_LENGTH_INCREASE:

                    if (_capacity + _increaseOnInBytes < upTo)
                    {
                        x = (int)Math.Ceiling((double)(upTo - _capacity) / (double)_increaseOnInBytes);
                    }
                    _capacity = _capacity + (_increaseOnInBytes * x);

                    break;
            }

            _nf = new byte[_capacity];
            Buffer.BlockCopy(_f, 0, _nf, 0, _ptrEnd);
            _f = _nf;
        }