mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-09-15 10:51:08 +02:00
* handle gracefully freeing a subblock that is located at the end of its block
(with no free space after it) in the win16 global heap manager git-svn-id: trunk@37636 -
This commit is contained in:
parent
87d5cc014f
commit
163ee92ef5
@ -215,20 +215,19 @@ circular linked list.
|
|||||||
begin
|
begin
|
||||||
PrevSubBlock:=nil;
|
PrevSubBlock:=nil;
|
||||||
CurSubBlock:=Ptr(CurBlock,CurBlockP^.FirstFreeOfs);
|
CurSubBlock:=Ptr(CurBlock,CurBlockP^.FirstFreeOfs);
|
||||||
while Ofs(CurSubBlock^)<Ofs(Addr^) do
|
while (Ofs(CurSubBlock^)<>0) and (Ofs(CurSubBlock^)<Ofs(Addr^)) do
|
||||||
begin
|
begin
|
||||||
PrevSubBlock:=CurSubBlock;
|
PrevSubBlock:=CurSubBlock;
|
||||||
CurSubBlock:=Ptr(CurBlock,CurSubBlock^.Next);
|
CurSubBlock:=Ptr(CurBlock,CurSubBlock^.Next);
|
||||||
if Ofs(CurSubBlock^)=0 then
|
|
||||||
HandleError(204);
|
|
||||||
end;
|
end;
|
||||||
if PrevSubBlock=nil then
|
if PrevSubBlock=nil then
|
||||||
HandleError(204);
|
HandleError(204);
|
||||||
|
{ merge with previous free block? }
|
||||||
if Ofs(PrevSubBlock^)+PrevSubBlock^.Size=Ofs(Addr^) then
|
if Ofs(PrevSubBlock^)+PrevSubBlock^.Size=Ofs(Addr^) then
|
||||||
begin
|
begin
|
||||||
Inc(PrevSubBlock^.Size,ASize);
|
Inc(PrevSubBlock^.Size,ASize);
|
||||||
{ merge with next as well? }
|
{ merge with next as well? }
|
||||||
if (Ofs(PrevSubBlock^)+PrevSubBlock^.Size)=Ofs(CurSubBlock^) then
|
if (Ofs(CurSubBlock^)<>0) and ((Ofs(PrevSubBlock^)+PrevSubBlock^.Size)=Ofs(CurSubBlock^)) then
|
||||||
begin
|
begin
|
||||||
Inc(PrevSubBlock^.Size,CurSubBlock^.Size);
|
Inc(PrevSubBlock^.Size,CurSubBlock^.Size);
|
||||||
PrevSubBlock^.Next:=CurSubBlock^.Next;
|
PrevSubBlock^.Next:=CurSubBlock^.Next;
|
||||||
@ -237,7 +236,7 @@ circular linked list.
|
|||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
PrevSubBlock^.Next:=Ofs(Addr^);
|
PrevSubBlock^.Next:=Ofs(Addr^);
|
||||||
if (Ofs(Addr^)+ASize)=Ofs(CurSubBlock^) then
|
if (Ofs(CurSubBlock^)<>0) and ((Ofs(Addr^)+ASize)=Ofs(CurSubBlock^)) then
|
||||||
with PFreeSubBlock(Addr)^ do
|
with PFreeSubBlock(Addr)^ do
|
||||||
begin
|
begin
|
||||||
Next:=CurSubBlock^.Next;
|
Next:=CurSubBlock^.Next;
|
||||||
|
Loading…
Reference in New Issue
Block a user