home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Black Box 4
/
BlackBox.cdr
/
progpas
/
u-heap.arj
/
SHOWHEAP.PAS
next >
Wrap
Pascal/Delphi Source File
|
1992-01-14
|
1KB
|
57 lines
Unit ShowHeap;
interface
uses
CRT,UMB_Heap;
Procedure Show_Heap;
implementation
type
PFreeRec = ^TFreeRec; { From pg. 216 of the TP6 programmer's guide. }
TFreeRec = record { It's used for traversing the free blocks of }
Next : PFreeRec; { the heap. }
Size : Pointer;
end;
Function Pointer_To_LongInt(P : Pointer) : LongInt;
type
PtrRec = record
Lo,Hi : Word;
end;
Begin
Pointer_To_LongInt := LongInt(PtrRec(P).Hi)*16+PtrRec(P).Lo;
End;
Procedure Show_Heap;
var
N : Word;
BlockSize,Total : LongInt;
Temp : PFreeRec;
Begin
N := 1;
Total := 0;
if (FreeList <> HeapPtr) then
begin
Temp := FreeList;
repeat
BlockSize := Pointer_To_LongInt(Temp^.Size);
Total := Total+BlockSize;
WriteLn(' Block ',N,' contains ',BlockSize:6,' bytes');
Inc(N);
Temp := Temp^.Next;
until (Temp = HeapPtr);
end;
BlockSize := Pointer_to_LongInt(HeapEnd)-Pointer_to_LongInt(HeapPtr);
WriteLn(' Block ',N,' contains ',BlockSize:6,' bytes');
Total := Total+BlockSize;
WriteLn(' -------------------------------');
WriteLn(' Total heap size = ',Total:6,' bytes');
WriteLn;
End;
BEGIN
END.