Browse Source

+ added the TP7-compatible pointer variables HeapOrg and HeapEnd, indicating,
respectively, the start and end of the tiny heap. Eventually they are also
going to be used for catching attempts to free memory that is outside the
heap.

git-svn-id: trunk@28437 -

nickysn 11 năm trước cách đây
mục cha
commit
9979aa702f
4 tập tin đã thay đổi với 25 bổ sung0 xóa
  1. 1 0
      .gitattributes
  2. 4 0
      rtl/inc/tinyheap.inc
  3. 19 0
      rtl/inc/tnyheaph.inc
  4. 1 0
      rtl/msdos/system.pp

+ 1 - 0
.gitattributes

@@ -8287,6 +8287,7 @@ rtl/inc/thread.inc svneol=native#text/plain
 rtl/inc/threadh.inc svneol=native#text/plain
 rtl/inc/threadvr.inc svneol=native#text/plain
 rtl/inc/tinyheap.inc svneol=native#text/plain
+rtl/inc/tnyheaph.inc svneol=native#text/plain
 rtl/inc/typefile.inc svneol=native#text/plain
 rtl/inc/ufloat128.pp svneol=native#text/plain
 rtl/inc/ustringh.inc svneol=native#text/plain

+ 4 - 0
rtl/inc/tinyheap.inc

@@ -271,6 +271,10 @@
         Inc(AAddress,alignment_inc);
         Dec(ASize,alignment_inc);
         Dec(ASize,ASize mod TinyHeapAllocGranularity);
+        if (HeapOrg=nil) or (TTinyHeapPointerArithmeticType(HeapOrg) > TTinyHeapPointerArithmeticType(AAddress)) then
+          HeapOrg:=AAddress;
+        if (HeapEnd=nil) or (TTinyHeapPointerArithmeticType(HeapEnd) < (TTinyHeapPointerArithmeticType(AAddress)+ASize)) then
+          HeapEnd:=Pointer(TTinyHeapPointerArithmeticType(AAddress)+ASize);
         InternalTinyFreeMem(AAddress, ASize);
       end;
 

+ 19 - 0
rtl/inc/tnyheaph.inc

@@ -0,0 +1,19 @@
+{
+    This file is part of the Free Pascal run time library.
+    Copyright (c) 2014 by the Free Pascal development team.
+
+    Tiny heap manager for the i8086 near heap, embedded targets, etc.
+
+    See the file COPYING.FPC, included in this distribution,
+    for details about the copyright.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ **********************************************************************}
+
+    var
+      { these vars are TP7-compatible }
+      HeapOrg: Pointer = nil;  { start of heap }
+      HeapEnd: Pointer = nil;  { end of heap }

+ 1 - 0
rtl/msdos/system.pp

@@ -14,6 +14,7 @@ interface
   $mode switch is not effective }
 
 {$I systemh.inc}
+{$I tnyheaph.inc}
 
 const
   LineEnding = #13#10;