Beispiel #1
0
        private void glueFreeBlocks()
        {
            RarMemBlock s0 = tempRarMemBlock1;

            s0.Address = tempMemBlockPos;
            RarMemBlock p = tempRarMemBlock2;
            RarMemBlock p1 = tempRarMemBlock3;
            int         i, k, sz;

            if (loUnit != hiUnit)
            {
                heap[loUnit] = 0;
            }
            for (i = 0, s0.SetPrev(s0), s0.SetNext(s0); i < N_INDEXES; i++)
            {
                while (freeList[i].GetNext() != 0)
                {
                    p.Address = removeNode(i); // =(RAR_MEM_BLK*)RemoveNode(i);
                    p.InsertAt(s0);            // p->insertAt(&s0);
                    p.Stamp = 0xFFFF;          // p->Stamp=0xFFFF;
                    p.SetNU(indx2Units[i]);    // p->NU=Indx2Units[i];
                }
            }
            for (p.Address = s0.GetNext(); p.Address != s0.Address; p.Address = p.GetNext())
            {
                // while ((p1=MBPtr(p,p->NU))->Stamp == 0xFFFF && int(p->NU)+p1->NU
                // < 0x10000)
                // Bug fixed
                p1.Address = MBPtr(p.Address, p.GetNU());
                while (p1.Stamp == 0xFFFF && p.GetNU() + p1.GetNU() < 0x10000)
                {
                    p1.Remove();
                    p.SetNU(p.GetNU() + p1.GetNU()); // ->NU += p1->NU;
                    p1.Address = MBPtr(p.Address, p.GetNU());
                }
            }

            // while ((p=s0.next) != &s0)
            // Bug fixed
            p.Address = s0.GetNext();
            while (p.Address != s0.Address)
            {
                for (p.Remove(), sz = p.GetNU(); sz > 128; sz -= 128, p.Address = MBPtr(p.Address, 128))
                {
                    insertNode(p.Address, N_INDEXES - 1);
                }
                if (indx2Units[i = units2Indx[sz - 1]] != sz)
                {
                    k = sz - indx2Units[--i];
                    insertNode(MBPtr(p.Address, sz - k), k - 1);
                }
                insertNode(p.Address, i);
                p.Address = s0.GetNext();
            }
        }
Beispiel #2
0
        internal void InsertAt(RarMemBlock p)
        {
            RarMemBlock temp = new RarMemBlock(Memory);

            SetPrev(p.Address);
            temp.Address = GetPrev();
            SetNext(temp.GetNext()); // prev.getNext();
            temp.SetNext(this);      // prev.setNext(this);
            temp.Address = GetNext();
            temp.SetPrev(this);      // next.setPrev(this);
        }
Beispiel #3
0
        internal void Remove()
        {
            RarMemBlock temp = new RarMemBlock(Memory);

            temp.Address = GetPrev();
            temp.SetNext(GetNext()); // prev.setNext(next);
            temp.Address = GetNext();
            temp.SetPrev(GetPrev()); // next.setPrev(prev);

            //		next = -1;
            //		prev = -1;
        }