/// <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); } } }
internal static void FreeStatic(ref Pointer data, int size) { Marshal.FreeHGlobal((IntPtr)data.GetDataClearOnly()); Interlocked.Add(ref staticSize, -size); }