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