浏览代码

* legacymem

marco 20 年之前
父节点
当前提交
25b8d4ac98
共有 1 个文件被更改,包括 61 次插入0 次删除
  1. 61 0
      rtl/inc/legacymem.pp

+ 61 - 0
rtl/inc/legacymem.pp

@@ -0,0 +1,61 @@
+unit legacymem;
+// temporary unit to bridge all the getfpcheapstatus/getheapstatus/memavail
+// problems in tests and demoes.
+
+interface 
+
+function getUsedbytes  :PtrInt;
+function getTotalBytes :PtrInt;
+
+implementation
+
+{$ifndef HASGETHEAPSTATUS}
+type
+  THeapStatus = record
+    MaxHeapSize,
+    MaxHeapUsed,
+    CurrHeapSize,
+    CurrHeapUsed,
+    CurrHeapFree  : ptrint;
+  end;
+
+{$endif HASGETHEAPSTATUS}
+
+{$ifndef HASGETFPCHEAPSTATUS}
+    type
+      TFPCHeapStatus = THeapStatus;
+{$endif HASGETFPCHEAPSTATUS}
+
+
+{$ifndef HASGETHEAPSTATUS}
+  procedure getheapstatus(var status:THeapStatus);
+  begin
+    fillchar(status,sizeof(status),0);
+    status.MaxHeapSize:=HeapSize;
+    status.MaxHeapUsed:=HeapSize-MemAvail;
+    status.CurrHeapSize:=HeapSize;
+    status.CurrHeapUsed:=HeapSize-MemAvail;
+    status.CurrHeapFree:=MemAvail;
+  end;
+{$endif HASGETHEAPSTATUS}
+
+{$ifndef HASGETFPCHEAPSTATUS}
+    function GetFPCHeapStatus:TFPCHeapStatus;
+    begin
+      GetHeapStatus(GetFPCHeapStatus);
+    end;
+{$endif HASGETFPCHEAPSTATUS}
+
+function getTotalBytes :PtrInt;
+
+begin
+  gettotalbytes:=GetFPCHeapStatus.CurrHeapsize;
+end;
+
+function getUsedBytes  :PtrInt;
+
+begin
+  getusedbytes:=GetFPCHeapStatus.CurrHeapsize;
+end;
+
+end.