コード例 #1
0
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (this.buffer != null)
                {
                    this.buffer.Dispose();
                    this.buffer = null;
                }
            }

            base.Dispose(disposing);
        }
コード例 #2
0
        public static SafeProcessHeapBuffer Create(ulong length)
        {
            try
            {
                SafeProcessHeapBuffer buffer = UnsafeNativeMethods.HeapAlloc(ProcessHeap, 0, (UIntPtr)length);

                if (buffer.IsInvalid)
                {
                    throw new OutOfMemoryException();
                }

                buffer.Initialize(length);

                return(buffer);
            }
            catch (OverflowException ex)
            {
                throw new OutOfMemoryException($"Overflow when attempting to allocate {length:F0} bytes.", ex);
            }
        }
コード例 #3
0
 public UnmanagedCompressedAV1Data(ulong size)
     : base(size)
 {
     this.buffer = SafeProcessHeapBuffer.Create(size);
 }