Esempio n. 1
0
        private void glueFreeBlocks()
        {
            RarMemBlock prev = this.tempRarMemBlock1;

            prev.Address = this.tempMemBlockPos;
            RarMemBlock block2 = this.tempRarMemBlock2;
            RarMemBlock block3 = this.tempRarMemBlock3;

            if (this.loUnit != this.hiUnit)
            {
                this.heap[this.loUnit] = 0;
            }
            int index = 0;

            prev.SetPrev(prev);
            prev.SetNext(prev);
            while (index < N_INDEXES)
            {
                while (this.freeList[index].GetNext() != 0)
                {
                    block2.Address = this.removeNode(index);
                    block2.InsertAt(prev);
                    block2.Stamp = 0xffff;
                    block2.SetNU(this.indx2Units[index]);
                }
                index++;
            }
            block2.Address = prev.GetNext();
            while (block2.Address != prev.Address)
            {
                block3.Address = this.MBPtr(block2.Address, block2.GetNU());
                while ((block3.Stamp == 0xffff) && ((block2.GetNU() + block3.GetNU()) < 0x10000))
                {
                    block3.Remove();
                    block2.SetNU(block2.GetNU() + block3.GetNU());
                    block3.Address = this.MBPtr(block2.Address, block2.GetNU());
                }
                block2.Address = block2.GetNext();
            }
            block2.Address = prev.GetNext();
            while (block2.Address != prev.Address)
            {
                block2.Remove();
                int nU = block2.GetNU();
                while (nU > 0x80)
                {
                    this.insertNode(block2.Address, N_INDEXES - 1);
                    nU            -= 0x80;
                    block2.Address = this.MBPtr(block2.Address, 0x80);
                }
                if (this.indx2Units[index = this.units2Indx[nU - 1]] != nU)
                {
                    int num2 = nU - this.indx2Units[--index];
                    this.insertNode(this.MBPtr(block2.Address, nU - num2), num2 - 1);
                }
                this.insertNode(block2.Address, index);
                block2.Address = prev.GetNext();
            }
        }
Esempio n. 2
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();
            }
        }