Browse Source

* use pointer arithmetic for doing address calculations, with a newly introduced
pointer type TTinyHeapPointerArithmeticType, instead of using ptruint. This
will allow us to use a huge pointer in i8086 far data memory models, in order
to allow the heap to exceed 64k.

git-svn-id: trunk@28247 -

nickysn 11 years ago
parent
commit
6f8a329b4c
1 changed files with 5 additions and 3 deletions
  1. 5 3
      rtl/inc/tinyheap.inc

+ 5 - 3
rtl/inc/tinyheap.inc

@@ -24,6 +24,8 @@
         part of the TTinyHeapBlock structure }
         part of the TTinyHeapBlock structure }
       TTinyHeapFreeBlockSize = PtrUInt;
       TTinyHeapFreeBlockSize = PtrUInt;
 
 
+      TTinyHeapPointerArithmeticType = ^Byte;
+
     const
     const
       TinyHeapMinBlock = 4*sizeof(pointer);
       TinyHeapMinBlock = 4*sizeof(pointer);
 
 
@@ -83,7 +85,7 @@
             PTinyHeapMemBlockSize(p)^ := size;
             PTinyHeapMemBlockSize(p)^ := size;
 
 
             if RestSize > 0 then
             if RestSize > 0 then
-              InternalTinyFreeMem(pointer(ptruint(p)+AllocSize), RestSize);
+              InternalTinyFreeMem(pointer(TTinyHeapPointerArithmeticType(p)+AllocSize), RestSize);
           end
           end
         else
         else
           if ReturnNilIfGrowHeapFails then
           if ReturnNilIfGrowHeapFails then
@@ -106,7 +108,7 @@
           begin
           begin
             mem := GetMem(Size+Alignment-1);
             mem := GetMem(Size+Alignment-1);
             memp := align(ptruint(mem), Alignment);
             memp := align(ptruint(mem), Alignment);
-            InternalTinyFreeMem(mem, ptruint(memp)-ptruint(mem));
+            InternalTinyFreeMem(mem, TTinyHeapPointerArithmeticType(memp)-TTinyHeapPointerArithmeticType(mem));
             result := pointer(memp);
             result := pointer(memp);
           end;
           end;
       end;
       end;
@@ -122,7 +124,7 @@
 
 
           b^.Next := TinyHeapBlocks;
           b^.Next := TinyHeapBlocks;
           b^.Size := Size;
           b^.Size := Size;
-          b^.EndAddr := pointer(ptruint(addr)+size);
+          b^.EndAddr := pointer(TTinyHeapPointerArithmeticType(addr)+size);
 
 
           if TinyHeapBlocks = nil then
           if TinyHeapBlocks = nil then
             TinyHeapBlocks := b
             TinyHeapBlocks := b