Example #1
0
        public virtual bool startSubAllocator(int SASize)
        {
            int num = SASize;

            if (this.subAllocatorSize != num)
            {
                this.stopSubAllocator();
                int num2 = ((num / 12) * UNIT_SIZE) + UNIT_SIZE;
                int num3 = (1 + num2) + (4 * N_INDEXES);
                this.tempMemBlockPos = num3;
                num3                 += 12;
                this.heap             = new byte[num3];
                this.heapStart        = 1;
                this.heapEnd          = (this.heapStart + num2) - UNIT_SIZE;
                this.subAllocatorSize = num;
                this.freeListPos      = this.heapStart + num2;
                int index = 0;
                for (int i = this.freeListPos; index < this.freeList.Length; i += 4)
                {
                    this.freeList[index]         = new RarNode(this.heap);
                    this.freeList[index].Address = i;
                    index++;
                }
                this.tempRarNode      = new RarNode(this.heap);
                this.tempRarMemBlock1 = new RarMemBlock(this.heap);
                this.tempRarMemBlock2 = new RarMemBlock(this.heap);
                this.tempRarMemBlock3 = new RarMemBlock(this.heap);
            }
            return(true);
        }
Example #2
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();
            }
        }
Example #3
0
        internal void Remove()
        {
            RarMemBlock block = new RarMemBlock(base.Memory);

            block.Address = this.GetPrev();
            block.SetNext(this.GetNext());
            block.Address = this.GetNext();
            block.SetPrev(this.GetPrev());
        }
Example #4
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);
 }
Example #5
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;
 }
Example #6
0
 internal void InsertAt(RarMemBlock p)
 {
     RarMemBlock block = new RarMemBlock(base.Memory);
     this.SetPrev(p.Address);
     block.Address = this.GetPrev();
     this.SetNext(block.GetNext());
     block.SetNext(this);
     block.Address = this.GetNext();
     block.SetPrev(this);
 }
Example #7
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();
            }
        }
Example #8
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;
        }
Example #9
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);
        }
Example #10
0
        internal void InsertAt(RarMemBlock p)
        {
            RarMemBlock block = new RarMemBlock(base.Memory);

            this.SetPrev(p.Address);
            block.Address = this.GetPrev();
            this.SetNext(block.GetNext());
            block.SetNext(this);
            block.Address = this.GetNext();
            block.SetPrev(this);
        }
Example #11
0
 public virtual void stopSubAllocator()
 {
     if (this.subAllocatorSize != 0)
     {
         this.subAllocatorSize = 0;
         this.heap             = null;
         this.heapStart        = 1;
         this.tempRarNode      = null;
         this.tempRarMemBlock1 = null;
         this.tempRarMemBlock2 = null;
         this.tempRarMemBlock3 = null;
     }
 }
Example #12
0
 public virtual void stopSubAllocator()
 {
     if (subAllocatorSize != 0)
     {
         subAllocatorSize = 0;
         //ArrayFactory.BYTES_FACTORY.recycle(heap);
         heap      = null;
         heapStart = 1;
         // rarfree(HeapStart);
         // Free temp fields
         tempRarNode      = null;
         tempRarMemBlock1 = null;
         tempRarMemBlock2 = null;
         tempRarMemBlock3 = null;
     }
 }
Example #13
0
        public virtual bool startSubAllocator(int SASize)
        {
            int t = SASize;

            if (subAllocatorSize == t)
            {
                return(true);
            }
            stopSubAllocator();
            int allocSize = t / FIXED_UNIT_SIZE * UNIT_SIZE + UNIT_SIZE;

            // adding space for freelist (needed for poiters)
            // 1+ for null pointer
            int realAllocSize = 1 + allocSize + 4 * N_INDEXES;

            // adding space for an additional memblock
            tempMemBlockPos = realAllocSize;
            realAllocSize  += RarMemBlock.size;

            heap             = new byte[realAllocSize];
            heapStart        = 1;
            heapEnd          = heapStart + allocSize - UNIT_SIZE;
            subAllocatorSize = t;
            // Bug fixed
            freeListPos = heapStart + allocSize;
            //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
            //assert(realAllocSize - tempMemBlockPos == RarMemBlock.size): realAllocSize
            //+   + tempMemBlockPos +   + RarMemBlock.size;

            // Init freeList
            for (int i = 0, pos = freeListPos; i < freeList.Length; i++, pos += RarNode.size)
            {
                freeList[i]         = new RarNode(heap);
                freeList[i].Address = pos;
            }

            // Init temp fields
            tempRarNode      = new RarNode(heap);
            tempRarMemBlock1 = new RarMemBlock(heap);
            tempRarMemBlock2 = new RarMemBlock(heap);
            tempRarMemBlock3 = new RarMemBlock(heap);

            return(true);
        }
Example #14
0
        public virtual bool startSubAllocator(int SASize)
        {
            int t = SASize;
            if (subAllocatorSize == t)
            {
                return true;
            }
            stopSubAllocator();
            int allocSize = t/FIXED_UNIT_SIZE*UNIT_SIZE + UNIT_SIZE;

            // adding space for freelist (needed for poiters)
            // 1+ for null pointer
            int realAllocSize = 1 + allocSize + 4*N_INDEXES;
            // adding space for an additional memblock
            tempMemBlockPos = realAllocSize;
            realAllocSize += RarMemBlock.size;

            heap = new byte[realAllocSize];
            heapStart = 1;
            heapEnd = heapStart + allocSize - UNIT_SIZE;
            subAllocatorSize = t;
            // Bug fixed
            freeListPos = heapStart + allocSize;
            //UPGRADE_ISSUE: The following fragment of code could not be parsed and was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1156'"
            //assert(realAllocSize - tempMemBlockPos == RarMemBlock.size): realAllocSize 
            //+   + tempMemBlockPos +   + RarMemBlock.size;

            // Init freeList
            for (int i = 0, pos = freeListPos; i < freeList.Length; i++, pos += RarNode.size)
            {
                freeList[i] = new RarNode(heap);
                freeList[i].Address = pos;
            }

            // Init temp fields
            tempRarNode = new RarNode(heap);
            tempRarMemBlock1 = new RarMemBlock(heap);
            tempRarMemBlock2 = new RarMemBlock(heap);
            tempRarMemBlock3 = new RarMemBlock(heap);

            return true;
        }
Example #15
0
 public virtual void stopSubAllocator()
 {
     if (subAllocatorSize != 0)
     {
         subAllocatorSize = 0;
         //ArrayFactory.BYTES_FACTORY.recycle(heap);
         heap = null;
         heapStart = 1;
         // rarfree(HeapStart);
         // Free temp fields
         tempRarNode = null;
         tempRarMemBlock1 = null;
         tempRarMemBlock2 = null;
         tempRarMemBlock3 = null;
     }
 }
Example #16
0
 public virtual void stopSubAllocator()
 {
     if (this.subAllocatorSize != 0)
     {
         this.subAllocatorSize = 0;
         this.heap = null;
         this.heapStart = 1;
         this.tempRarNode = null;
         this.tempRarMemBlock1 = null;
         this.tempRarMemBlock2 = null;
         this.tempRarMemBlock3 = null;
     }
 }
Example #17
0
 public virtual bool startSubAllocator(int SASize)
 {
     int num = SASize;
     if (this.subAllocatorSize != num)
     {
         this.stopSubAllocator();
         int num2 = ((num / 12) * UNIT_SIZE) + UNIT_SIZE;
         int num3 = (1 + num2) + (4 * N_INDEXES);
         this.tempMemBlockPos = num3;
         num3 += 12;
         this.heap = new byte[num3];
         this.heapStart = 1;
         this.heapEnd = (this.heapStart + num2) - UNIT_SIZE;
         this.subAllocatorSize = num;
         this.freeListPos = this.heapStart + num2;
         int index = 0;
         for (int i = this.freeListPos; index < this.freeList.Length; i += 4)
         {
             this.freeList[index] = new RarNode(this.heap);
             this.freeList[index].Address = i;
             index++;
         }
         this.tempRarNode = new RarNode(this.heap);
         this.tempRarMemBlock1 = new RarMemBlock(this.heap);
         this.tempRarMemBlock2 = new RarMemBlock(this.heap);
         this.tempRarMemBlock3 = new RarMemBlock(this.heap);
     }
     return true;
 }
Example #18
0
 internal void Remove()
 {
     RarMemBlock block = new RarMemBlock(base.Memory);
     block.Address = this.GetPrev();
     block.SetNext(this.GetNext());
     block.Address = this.GetNext();
     block.SetPrev(this.GetPrev());
 }
Example #19
0
 internal void SetPrev(RarMemBlock prev)
 {
     SetPrev(prev.Address);
 }
Example #20
0
 internal void SetPrev(RarMemBlock prev)
 {
     this.SetPrev(prev.Address);
 }
Example #21
0
 internal void SetNext(RarMemBlock next)
 {
     this.SetNext(next.Address);
 }
Example #22
0
 internal void SetNext(RarMemBlock next)
 {
     SetNext(next.Address);
 }