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(); } }
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; } }
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); }