示例#1
0
        public ushort FreeSelector(ushort selector, ushort pages = 1)
        {
            if (selector == 0)
            {
                return(0);
            }

            // Get the selector index
            int selectorIndex = selector >> 3;

            Selector sel;

            sel = _pageMap[selectorIndex];
            if (sel == null)
            {
                return(0);
            }

            // Multi segment
            _selectorAllocator.Free(_selectorAllocator.AllocationFromPosition(selectorIndex));

            // Remove from page map
            for (int i = 0; i < pages; i++)
            {
                _pageMap[sel.selectorIndex + i] = null;
            }

            if (_machine.logGlobalAllocations)
            {
                Log.WriteLine("Freed selector: 0x{0:X4} ({1} pages)", sel.selector, pages);
            }

            return(0);
        }
示例#2
0
        public bool Free(ushort handle)
        {
            // Get allocation from handle or pointer
            var alloc = FromHandle(handle);

            if (alloc == null)
            {
                return(false);
            }

            // Remove from allocations table
            _handleOrPtrMap.Remove(alloc.handleOrPtr);

            // Release the handle
            if (alloc.Moveable)
            {
                FreeHandle(alloc.handleOrPtr);
            }

            // Remove from allocator
            _allocator.Free(alloc.range);
            return(true);
        }