/// <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; }
/// <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; }
internal Pointer GetMinSize(int minSize) { return(minSize <= Size?GetPointer() : Unmanaged.GetPointer(minSize, false)); }
public Pointer GetPointer() { byte *data = tryGet(); return(data != null ? new Pointer(data, Size) : Unmanaged.GetPointer(Size, false)); }