* rm EndAddr from the TTinyHeapBlock structure. This:

1) fixes a bug, which causes the next TTinyHeapBlock to be overwritten after
     freeing a memory block, allocated by GetMem(sizeof(pointer)). This bug was
     exposed after r28391, but was present before that; this commit only made
     the damage worse and, therefore, more visible.
  2) brings the internal heap structure closer to the TP7 heap.

git-svn-id: trunk@28416 -
This commit is contained in:
nickysn 2014-08-15 00:33:33 +00:00
parent 7ceda16e13
commit 14057ef438

View File

@ -41,7 +41,6 @@
TTinyHeapBlock = record
Next: PTinyHeapBlock;
Size: TTinyHeapFreeBlockSize;
EndAddr: pointer;
end;
const
@ -126,6 +125,7 @@
procedure InternalTinyFreeMem(Addr: Pointer; Size: TTinyHeapFreeBlockSize);
var
b, p, prev: PTinyHeapBlock;
EndAddr: Pointer;
concatenated: boolean;
begin
repeat
@ -134,7 +134,7 @@
b^.Next := TinyHeapBlocks;
b^.Size := Size;
b^.EndAddr := pointer(TTinyHeapPointerArithmeticType(addr)+size);
EndAddr := pointer(TTinyHeapPointerArithmeticType(addr)+size);
if TinyHeapBlocks = nil then
TinyHeapBlocks := b
@ -145,7 +145,7 @@
while assigned(p) do
begin
if p^.EndAddr = addr then
if (TTinyHeapPointerArithmeticType(p)+p^.Size) = TTinyHeapPointerArithmeticType(Addr) then
begin
addr:=p;
size:=p^.size+size;
@ -156,7 +156,7 @@
concatenated:=true;
break;
end
else if p = b^.EndAddr then
else if p = EndAddr then
begin
size:=p^.size+size;
if prev = nil then