mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-27 19:10:14 +02:00
* 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:
parent
7ceda16e13
commit
14057ef438
@ -41,7 +41,6 @@
|
|||||||
TTinyHeapBlock = record
|
TTinyHeapBlock = record
|
||||||
Next: PTinyHeapBlock;
|
Next: PTinyHeapBlock;
|
||||||
Size: TTinyHeapFreeBlockSize;
|
Size: TTinyHeapFreeBlockSize;
|
||||||
EndAddr: pointer;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
const
|
const
|
||||||
@ -126,6 +125,7 @@
|
|||||||
procedure InternalTinyFreeMem(Addr: Pointer; Size: TTinyHeapFreeBlockSize);
|
procedure InternalTinyFreeMem(Addr: Pointer; Size: TTinyHeapFreeBlockSize);
|
||||||
var
|
var
|
||||||
b, p, prev: PTinyHeapBlock;
|
b, p, prev: PTinyHeapBlock;
|
||||||
|
EndAddr: Pointer;
|
||||||
concatenated: boolean;
|
concatenated: boolean;
|
||||||
begin
|
begin
|
||||||
repeat
|
repeat
|
||||||
@ -134,7 +134,7 @@
|
|||||||
|
|
||||||
b^.Next := TinyHeapBlocks;
|
b^.Next := TinyHeapBlocks;
|
||||||
b^.Size := Size;
|
b^.Size := Size;
|
||||||
b^.EndAddr := pointer(TTinyHeapPointerArithmeticType(addr)+size);
|
EndAddr := pointer(TTinyHeapPointerArithmeticType(addr)+size);
|
||||||
|
|
||||||
if TinyHeapBlocks = nil then
|
if TinyHeapBlocks = nil then
|
||||||
TinyHeapBlocks := b
|
TinyHeapBlocks := b
|
||||||
@ -145,7 +145,7 @@
|
|||||||
|
|
||||||
while assigned(p) do
|
while assigned(p) do
|
||||||
begin
|
begin
|
||||||
if p^.EndAddr = addr then
|
if (TTinyHeapPointerArithmeticType(p)+p^.Size) = TTinyHeapPointerArithmeticType(Addr) then
|
||||||
begin
|
begin
|
||||||
addr:=p;
|
addr:=p;
|
||||||
size:=p^.size+size;
|
size:=p^.size+size;
|
||||||
@ -156,7 +156,7 @@
|
|||||||
concatenated:=true;
|
concatenated:=true;
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
else if p = b^.EndAddr then
|
else if p = EndAddr then
|
||||||
begin
|
begin
|
||||||
size:=p^.size+size;
|
size:=p^.size+size;
|
||||||
if prev = nil then
|
if prev = nil then
|
||||||
|
Loading…
Reference in New Issue
Block a user