mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 09:09:19 +02:00
* don't hard-code size of linebuf entries
* use reallocmem when growing linebuf instead of getmem+move git-svn-id: trunk@27792 -
This commit is contained in:
parent
656ba70fd8
commit
5e76203bc3
@ -226,7 +226,7 @@ uses
|
|||||||
close;
|
close;
|
||||||
{ free memory }
|
{ free memory }
|
||||||
if assigned(linebuf) then
|
if assigned(linebuf) then
|
||||||
freemem(linebuf,maxlinebuf shl 2);
|
freemem(linebuf,maxlinebuf*sizeof(linebuf^[0]));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -368,24 +368,16 @@ uses
|
|||||||
|
|
||||||
|
|
||||||
procedure tinputfile.setline(line,linepos:longint);
|
procedure tinputfile.setline(line,linepos:longint);
|
||||||
var
|
|
||||||
oldlinebuf : plongintarr;
|
|
||||||
begin
|
begin
|
||||||
if line<1 then
|
if line<1 then
|
||||||
exit;
|
exit;
|
||||||
while (line>=maxlinebuf) do
|
while (line>=maxlinebuf) do
|
||||||
begin
|
begin
|
||||||
oldlinebuf:=linebuf;
|
{ create new linebuf and move old info }
|
||||||
{ create new linebuf and move old info }
|
linebuf:=reallocmem(linebuf,(maxlinebuf+linebufincrease)*sizeof(linebuf^[0]));
|
||||||
getmem(linebuf,(maxlinebuf+linebufincrease) shl 2);
|
fillchar(linebuf^[maxlinebuf],linebufincrease*sizeof(linebuf^[0]),0);
|
||||||
if assigned(oldlinebuf) then
|
inc(maxlinebuf,linebufincrease);
|
||||||
begin
|
end;
|
||||||
move(oldlinebuf^,linebuf^,maxlinebuf shl 2);
|
|
||||||
freemem(oldlinebuf,maxlinebuf shl 2);
|
|
||||||
end;
|
|
||||||
fillchar(linebuf^[maxlinebuf],linebufincrease shl 2,0);
|
|
||||||
inc(maxlinebuf,linebufincrease);
|
|
||||||
end;
|
|
||||||
linebuf^[line]:=linepos;
|
linebuf^[line]:=linepos;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user