Esempio n. 1
0
 private void ReleaseHandle()
 {
     if (this.handle != null)
     {
         HeapHandleCache.Instance.Release(this.handle);
         this.handle   = null;
         this.capacity = 0;
     }
 }
Esempio n. 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);
            }
        }
Esempio n. 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;
        }
Esempio n. 4
0
 private void ReleaseHandle()
 {
     if (this.handle != null)
     {
         HeapHandleCache.Instance.Release(this.handle);
         this.handle = null;
         this.capacity = 0;
     }
 }
Esempio n. 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);
            }
        }
Esempio n. 6
0
 private void ReleaseHandle()
 {
     if (_handle != null)
     {
         HeapHandleCache.Instance.Release(_handle);
         _handle = null;
         _byteCapacity = 0;
     }
 }