示例#1
0
文件: Buffer.cs 项目: Crysty-Yui/ice
 public Buffer(ByteBuffer.ByteOrder order)
 {
     b = _emptyBuffer;
     _size = 0;
     _capacity = 0;
     _order = order;
 }
示例#2
0
文件: Buffer.cs 项目: bholl/zeroc-ice
 public Buffer(int maxCapacity)
 {
     b = _emptyBuffer;
     _size = 0;
     _capacity = 0;
     _maxCapacity = maxCapacity;
 }
示例#3
0
文件: Buffer.cs 项目: Crysty-Yui/ice
 public Buffer(ByteBuffer data, ByteBuffer.ByteOrder order)
 {
     b = data;
     b.order(order);
     _size = data.remaining();
     _capacity = 0;
     _order = order;
 }
示例#4
0
文件: Buffer.cs 项目: Crysty-Yui/ice
 public Buffer(byte[] data, ByteBuffer.ByteOrder order)
 {
     b = ByteBuffer.wrap(data);
     b.order(order);
     _size = data.Length;
     _capacity = 0;
     _order = order;
 }
示例#5
0
文件: Buffer.cs 项目: Crysty-Yui/ice
        public Buffer(Buffer buf, bool adopt)
        {
            b = buf.b;
            _size = buf._size;
            _capacity = buf._capacity;
            _shrinkCounter = buf._shrinkCounter;
            _order = buf._order;

            if(adopt)
            {
                buf.clear();
            }
        }
示例#6
0
文件: Buffer.cs 项目: Crysty-Yui/ice
 public void clear()
 {
     b = _emptyBuffer;
     _size = 0;
     _capacity = 0;
     _shrinkCounter = 0;
 }
示例#7
0
文件: Buffer.cs 项目: Crysty-Yui/ice
 public Buffer(ByteBuffer data)
     : this(data, ByteBuffer.ByteOrder.LITTLE_ENDIAN)
 {
 }
示例#8
0
文件: Buffer.cs 项目: Crysty-Yui/ice
        private void reserve(int n)
        {
            Debug.Assert(_capacity == b.capacity());

            if(n > _capacity)
            {
                _capacity = System.Math.Max(n, 2 * _capacity);
                _capacity = System.Math.Max(240, _capacity);
            }
            else if(n < _capacity)
            {
                _capacity = n;
            }
            else
            {
                return;
            }

            try
            {
                ByteBuffer buf = ByteBuffer.allocate(_capacity);

                if(b == _emptyBuffer)
                {
                    b = buf;
                }
                else
                {
                    int pos = b.position();
                    b.position(0);
                    b.limit(System.Math.Min(_capacity, b.capacity()));
                    buf.put(b);
                    b = buf;
                    b.limit(b.capacity());
                    b.position(pos);
                }

                b.order(_order);
            }
            catch(System.OutOfMemoryException)
            {
                _capacity = b.capacity(); // Restore the previous capacity
                throw;
            }
            catch(System.Exception ex)
            {
                _capacity = b.capacity(); // Restore the previous capacity.
                Ice.MarshalException e = new Ice.MarshalException(ex);
                e.reason = "unexpected exception while trying to allocate a ByteBuffer:\n" + ex;
                throw e;
            }
            finally
            {
                Debug.Assert(_capacity == b.capacity());
            }
        }
示例#9
0
文件: Buffer.cs 项目: bholl/zeroc-ice
 public void clear()
 {
     b = _emptyBuffer;
     _size = 0;
     _capacity = 0;
 }