Пример #1
0
 /// <summary>
 /// 重置数据
 /// </summary>
 /// <param name="data">数据</param>
 internal virtual void Reset(ref Pointer data)
 {
     if (IsUnmanaged)
     {
         Unmanaged.Free(ref Data);
         IsUnmanaged = false;
     }
     Data         = data;
     LastPrepSize = 0;
 }
Пример #2
0
 /// <summary>
 /// 释放数据容器
 /// </summary>
 public virtual void Close()
 {
     if (IsUnmanaged)
     {
         Unmanaged.Free(ref Data);
         IsUnmanaged       = false;
         Data.CurrentIndex = 0;
     }
     else
     {
         Data.SetNull();
     }
     LastPrepSize = 0;
 }
Пример #3
0
        /// <summary>
        /// 保存缓冲区
        /// </summary>
        /// <param name="buffer">缓冲区</param>
        public void Push(ref Pointer buffer)
        {
            int size = System.Threading.Interlocked.Exchange(ref buffer.ByteSize, 0);

            if (size != 0)
            {
                if (size == Size)
                {
                    Push((byte *)buffer.GetDataClearOnly());
                }
                else
                {
                    Unmanaged.Free(ref buffer, size);
                }
            }
        }
Пример #4
0
 /// <summary>
 /// 重置数据
 /// </summary>
 /// <param name="size">数据字节长度</param>
 internal virtual void Reset(int size = UnmanagedPool.TinySize)
 {
     if (size <= 0)
     {
         size = UnmanagedPool.TinySize;
     }
     if (size != Data.ByteSize)
     {
         if (IsUnmanaged)
         {
             Unmanaged.Free(ref this.Data);
             IsUnmanaged = false;
         }
         Data        = Unmanaged.GetPointer(size, false);
         IsUnmanaged = true;
     }
     Data.CurrentIndex = LastPrepSize = 0;
 }
Пример #5
0
        /// <summary>
        /// 设置容器字节尺寸
        /// </summary>
        /// <param name="size">容器字节尺寸</param>
        protected void setStreamSize(int size)
        {
#if DEBUG
            if (size <= 0)
            {
                throw new Exception(size.toString() + " <= 0");
            }
#endif
            if (size < UnmanagedPool.TinySize)
            {
                size = UnmanagedPool.TinySize;
            }
            Pointer newData = Unmanaged.GetPointer(size, false);
            Data.CopyTo(ref newData);
            if (IsUnmanaged)
            {
                Unmanaged.Free(ref Data);
            }
            Data        = newData;
            IsUnmanaged = true;
        }