예제 #1
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;
 }
예제 #2
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;
        }
예제 #3
0
 internal Pointer GetMinSize(int minSize)
 {
     return(minSize <= Size?GetPointer() : Unmanaged.GetPointer(minSize, false));
 }
예제 #4
0
        public Pointer GetPointer()
        {
            byte *data = tryGet();

            return(data != null ? new Pointer(data, Size) : Unmanaged.GetPointer(Size, false));
        }