public void update() { Hashtable pLines = mpOwnerAlloc.getLineAllocations(); if (!Expanded) { this.Nodes.Clear(); if (pLines.Count > 0) { Nodes.Add(new GDITreeViewNode()); } } else { this.Nodes.Clear(); ////////////////// //per line IDictionaryEnumerator line_enumerator = pLines.GetEnumerator(); while (line_enumerator.MoveNext()) { LineAlloc la = ((LineAlloc)line_enumerator.Value); if (la != null) { LineAllocNode lan = new LineAllocNode(la); addNode(lan); } } } this.Text = MemoryNumber.convert(mpOwnerAlloc.getTotalAllocatedBytes(false)) + "\t" + mpOwnerAlloc.getFilename(); }
//============================================================================== // getBlockSize //============================================================================== public uint getBlockSize(uint pBlock) { LineAlloc la = getLineContaining(pBlock); if (la == null) { return(0); } return(la.getBlockSize(pBlock)); }
//============================================================================== // getLineContaining //============================================================================== public LineAlloc getLineContaining(uint pBlock) { if (!mBlockToLineNum.Contains(pBlock)) { return(null); } uint lineNum = (uint)mBlockToLineNum[pBlock]; LineAlloc la = (LineAlloc)mAllocations[lineNum]; return(la); }
//============================================================================== // deleteMem //============================================================================== public void deleteMem(uint pBlock) { LineAlloc la = getLineContaining(pBlock); mBlockToLineNum.Remove(pBlock); if (la != null) { mTotalBytes -= la.getBlockSize(pBlock); la.deleteMem(pBlock); if (la.getTotalAllocatedBytes() == 0) { mAllocations.Remove(la); } return; } GlobalErrors.addError("FileAlloc : Stray Delete of block 0x" + pBlock.ToString("x")); }
//========================================= // allocMem //========================================= public void allocMem(uint pHeap, uint pBlock, uint blockSize, uint lineNum, HaloWarsMem.BALContext context) { if (mBlockToLineNum.Contains(pBlock)) { GlobalErrors.addError("FileAlloc : Multiple Allocations of block 0x" + pBlock.ToString("x") + " in heap 0x" + pHeap.ToString("x")); return; } LineAlloc la = (LineAlloc)mAllocations[lineNum]; if (la == null) { la = new LineAlloc(lineNum); mAllocations.Add(lineNum, la); } la.allocMem(pHeap, pBlock, blockSize, context); mBlockToLineNum.Add(pBlock, lineNum); mTotalBytes += blockSize; }
public LineAllocNode(LineAlloc ownerAlloc) { mpOwnerAlloc = ownerAlloc; this.Text = MemoryNumber.convert(mpOwnerAlloc.getTotalAllocatedBytes()) + " from " + mpOwnerAlloc.getTotalNumAllocations() + " allocations at Line " + mpOwnerAlloc.getLinenum(); }