Example #1
0
 private void ReleaseHandle()
 {
     if (this.handle != null)
     {
         HeapHandleCache.Instance.Release(this.handle);
         this.handle   = null;
         this.capacity = 0;
     }
 }
Example #2
0
        private unsafe void Resize(ulong byteLength)
        {
            if (byteLength == 0)
            {
                this.ReleaseHandle();
                return;
            }

            if (this.handle == null)
            {
                this.handle = HeapHandleCache.Instance.Acquire(byteLength);
            }
            else
            {
                this.handle.Resize(byteLength);
            }
        }
Example #3
0
        public IntPtr Resize(uint size)
        {
            HeapHandle newHandle = this.Handle == IntPtr.Zero
                ? HeapAlloc(ProcessHeap, 0, (UIntPtr)size)
                : HeapReAlloc(ProcessHeap, 0, this.Handle, (UIntPtr)size);

            if (newHandle.IsInvalid)
            {
                throw new InvalidOperationException("Could not allocate requested memory.");
            }

            this.handle = newHandle;
            this.Size = size;
            return this.Handle;
        }
Example #4
0
 private void ReleaseHandle()
 {
     if (this.handle != null)
     {
         HeapHandleCache.Instance.Release(this.handle);
         this.handle = null;
         this.capacity = 0;
     }
 }
Example #5
0
        private unsafe void Resize(ulong byteLength)
        {
            if (byteLength == 0)
            {
                this.ReleaseHandle();
                return;
            }

            if (this.handle == null)
            {
                this.handle = HeapHandleCache.Instance.Acquire(byteLength);
            }
            else
            {
                this.handle.Resize(byteLength);
            }
        }
Example #6
0
 private void ReleaseHandle()
 {
     if (_handle != null)
     {
         HeapHandleCache.Instance.Release(_handle);
         _handle = null;
         _byteCapacity = 0;
     }
 }