mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 16:09:17 +02:00
* fixed bug in TryBlockGetMem, caused by ambigous variable named 'Size' in with statement
git-svn-id: trunk@37641 -
This commit is contained in:
parent
ea8fc43f52
commit
ca7da11bb6
@ -78,8 +78,8 @@ circular linked list.
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
{ tries to suballocate from the existing blocks. Returns nil if not enough
|
{ tries to suballocate from the existing blocks. Returns nil if not enough
|
||||||
free space is available. Size must be aligned by 4. }
|
free space is available. ASize must be aligned by 4. }
|
||||||
function TryBlockGetMem(Size: Word): FarPointer;
|
function TryBlockGetMem(ASize: Word): FarPointer;
|
||||||
var
|
var
|
||||||
CurBlock: Word;
|
CurBlock: Word;
|
||||||
CurBlockP: PGlobalHeapBlockHeader;
|
CurBlockP: PGlobalHeapBlockHeader;
|
||||||
@ -91,16 +91,16 @@ circular linked list.
|
|||||||
exit;
|
exit;
|
||||||
repeat
|
repeat
|
||||||
CurBlockP:=Ptr(CurBlock,0);
|
CurBlockP:=Ptr(CurBlock,0);
|
||||||
if CurBlockP^.TotalFreeSpaceInBlock>=Size then
|
if CurBlockP^.TotalFreeSpaceInBlock>=ASize then
|
||||||
begin
|
begin
|
||||||
PrevSubBlock:=nil;
|
PrevSubBlock:=nil;
|
||||||
CurSubBlock:=Ptr(CurBlock,CurBlockP^.FirstFreeOfs);
|
CurSubBlock:=Ptr(CurBlock,CurBlockP^.FirstFreeOfs);
|
||||||
while Ofs(CurSubBlock^)<>0 do
|
while Ofs(CurSubBlock^)<>0 do
|
||||||
begin
|
begin
|
||||||
if CurSubBlock^.Size>=Size then
|
if CurSubBlock^.Size>=ASize then
|
||||||
begin
|
begin
|
||||||
result:=CurSubBlock;
|
result:=CurSubBlock;
|
||||||
if CurSubBlock^.Size=Size then
|
if CurSubBlock^.Size=ASize then
|
||||||
begin
|
begin
|
||||||
if PrevSubBlock<>nil then
|
if PrevSubBlock<>nil then
|
||||||
PrevSubBlock^.Next:=CurSubBlock^.Next
|
PrevSubBlock^.Next:=CurSubBlock^.Next
|
||||||
@ -109,17 +109,17 @@ circular linked list.
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
with PFreeSubBlock(Ptr(CurBlock,Ofs(CurSubBlock^)+Size))^ do
|
with PFreeSubBlock(Ptr(CurBlock,Ofs(CurSubBlock^)+ASize))^ do
|
||||||
begin
|
begin
|
||||||
Next:=CurSubBlock^.Next;
|
Next:=CurSubBlock^.Next;
|
||||||
Size:=CurSubBlock^.Size-Size;
|
Size:=CurSubBlock^.Size-ASize;
|
||||||
end;
|
end;
|
||||||
if PrevSubBlock<>nil then
|
if PrevSubBlock<>nil then
|
||||||
PrevSubBlock^.Next:=Ofs(CurSubBlock^)+Size
|
PrevSubBlock^.Next:=Ofs(CurSubBlock^)+ASize
|
||||||
else
|
else
|
||||||
CurBlockP^.FirstFreeOfs:=Ofs(CurSubBlock^)+Size;
|
CurBlockP^.FirstFreeOfs:=Ofs(CurSubBlock^)+ASize;
|
||||||
end;
|
end;
|
||||||
Dec(CurBlockP^.TotalFreeSpaceInBlock,Size);
|
Dec(CurBlockP^.TotalFreeSpaceInBlock,ASize);
|
||||||
{ TODO: what is FirstFreeOfs if the entire block is allocated??? }
|
{ TODO: what is FirstFreeOfs if the entire block is allocated??? }
|
||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
Loading…
Reference in New Issue
Block a user