示例#1
0
        private void GlueFreeBlocks()
        {
            MemoryNode memoryNode = new MemoryNode(LocalOffset, Memory);

            memoryNode.Stamp     = 0;
            memoryNode.Next      = MemoryNode.Zero;
            memoryNode.UnitCount = 0;

            MemoryNode memoryNode0;
            MemoryNode memoryNode1;
            MemoryNode memoryNode2;

            if (LowUnit != HighUnit)
            {
                LowUnit[0] = 0;
            }

            // Find all unused memory nodes.

            memoryNode1 = memoryNode;
            for (uint index = 0; index < IndexCount; index++)
            {
                while (MemoryNodes[index].Available)
                {
                    memoryNode0 = MemoryNodes[index].Remove();
                    if (memoryNode0.UnitCount != 0)
                    {
                        while ((memoryNode2 = memoryNode0 + memoryNode0.UnitCount).Stamp == uint.MaxValue)
                        {
                            memoryNode0.UnitCount = memoryNode0.UnitCount + memoryNode2.UnitCount;
                            memoryNode2.UnitCount = 0;
                        }
                        memoryNode1.Link(memoryNode0);
                        memoryNode1 = memoryNode0;
                    }
                }
            }

            // Coalesce the memory represented by the unused memory nodes.

            while (memoryNode.Available)
            {
                memoryNode0 = memoryNode.Remove();
                uint unitCount = memoryNode0.UnitCount;
                if (unitCount != 0)
                {
                    for (; unitCount > 128; unitCount -= 128, memoryNode0 += 128)
                    {
                        MemoryNodes[IndexCount - 1].Insert(memoryNode0, 128);
                    }

                    uint index = unitsToIndex[unitCount - 1];
                    if (indexToUnits[index] != unitCount)
                    {
                        uint unitCountDifference = unitCount - indexToUnits[--index];
                        MemoryNodes[unitCountDifference - 1].Insert(memoryNode0 + (unitCount - unitCountDifference), unitCountDifference);
                    }

                    MemoryNodes[index].Insert(memoryNode0, indexToUnits[index]);
                }
            }

            GlueCount = 1 << 13;
        }
示例#2
0
        private void GlueFreeBlocks()
        {
            MemoryNode memoryNode = new MemoryNode(LOCAL_OFFSET, _memory);

            memoryNode.Stamp     = 0;
            memoryNode.Next      = MemoryNode.ZERO;
            memoryNode.UnitCount = 0;

            MemoryNode memoryNode0;
            MemoryNode memoryNode1;
            MemoryNode memoryNode2;

            if (_lowUnit != _highUnit)
            {
                _lowUnit[0] = 0;
            }

            // Find all unused memory nodes.

            memoryNode1 = memoryNode;
            for (uint index = 0; index < INDEX_COUNT; index++)
            {
                while (_memoryNodes[index].Available)
                {
                    memoryNode0 = _memoryNodes[index].Remove();
                    if (memoryNode0.UnitCount != 0)
                    {
                        while ((memoryNode2 = memoryNode0 + memoryNode0.UnitCount).Stamp == uint.MaxValue)
                        {
                            memoryNode0.UnitCount = memoryNode0.UnitCount + memoryNode2.UnitCount;
                            memoryNode2.UnitCount = 0;
                        }
                        memoryNode1.Link(memoryNode0);
                        memoryNode1 = memoryNode0;
                    }
                }
            }

            // Coalesce the memory represented by the unused memory nodes.

            while (memoryNode.Available)
            {
                memoryNode0 = memoryNode.Remove();
                uint unitCount = memoryNode0.UnitCount;
                if (unitCount != 0)
                {
                    for (; unitCount > 128; unitCount -= 128, memoryNode0 += 128)
                    {
                        _memoryNodes[INDEX_COUNT - 1].Insert(memoryNode0, 128);
                    }

                    uint index = UNITS_TO_INDEX[unitCount - 1];
                    if (INDEX_TO_UNITS[index] != unitCount)
                    {
                        uint unitCountDifference = unitCount - INDEX_TO_UNITS[--index];
                        _memoryNodes[unitCountDifference - 1].Insert(memoryNode0 + (unitCount - unitCountDifference),
                                                                     unitCountDifference);
                    }

                    _memoryNodes[index].Insert(memoryNode0, INDEX_TO_UNITS[index]);
                }
            }

            _glueCount = 1 << 13;
        }
        private void GlueFreeBlocks()
        {
            MemoryNode memoryNode = new MemoryNode(LocalOffset, Memory);
            memoryNode.Stamp = 0;
            memoryNode.Next = MemoryNode.Zero;
            memoryNode.UnitCount = 0;

            MemoryNode memoryNode0;
            MemoryNode memoryNode1;
            MemoryNode memoryNode2;

            if (LowUnit != HighUnit)
                LowUnit[0] = 0;

            // Find all unused memory nodes.

            memoryNode1 = memoryNode;
            for (uint index = 0; index < IndexCount; index++)
            {
                while (MemoryNodes[index].Available)
                {
                    memoryNode0 = MemoryNodes[index].Remove();
                    if (memoryNode0.UnitCount != 0)
                    {
                        while ((memoryNode2 = memoryNode0 + memoryNode0.UnitCount).Stamp == uint.MaxValue)
                        {
                            memoryNode0.UnitCount = memoryNode0.UnitCount + memoryNode2.UnitCount;
                            memoryNode2.UnitCount = 0;
                        }
                        memoryNode1.Link(memoryNode0);
                        memoryNode1 = memoryNode0;
                    }
                }
            }

            // Coalesce the memory represented by the unused memory nodes.

            while (memoryNode.Available)
            {
                memoryNode0 = memoryNode.Remove();
                uint unitCount = memoryNode0.UnitCount;
                if (unitCount != 0)
                {
                    for (; unitCount > 128; unitCount -= 128, memoryNode0 += 128)
                        MemoryNodes[IndexCount - 1].Insert(memoryNode0, 128);

                    uint index = unitsToIndex[unitCount - 1];
                    if (indexToUnits[index] != unitCount)
                    {
                        uint unitCountDifference = unitCount - indexToUnits[--index];
                        MemoryNodes[unitCountDifference - 1].Insert(memoryNode0 + (unitCount - unitCountDifference), unitCountDifference);
                    }

                    MemoryNodes[index].Insert(memoryNode0, indexToUnits[index]);
                }
            }

            GlueCount = 1 << 13;
        }