mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-21 01:49:08 +02:00
Restored array of Sw_Word to array of Word as those are ment to be video buffer cells.
This commit is contained in:
parent
f0760bacc0
commit
f3eb7f8608
@ -1892,7 +1892,7 @@ end; { TEditor.Draw }
|
|||||||
procedure TEditor.DrawLines (Y, Count : Sw_Integer; LinePtr : Sw_Word);
|
procedure TEditor.DrawLines (Y, Count : Sw_Integer; LinePtr : Sw_Word);
|
||||||
VAR
|
VAR
|
||||||
Color : Word;
|
Color : Word;
|
||||||
B : array[0..MaxLineLength - 1] of Sw_Word;
|
B : array[0..MaxLineLength - 1] of Word; { This is array of video buffer cells. Has to be Word}
|
||||||
begin
|
begin
|
||||||
Color := GetColor ($0201);
|
Color := GetColor ($0201);
|
||||||
while Count > 0 do
|
while Count > 0 do
|
||||||
@ -3020,8 +3020,25 @@ end; { TEditor.SetBufLen }
|
|||||||
|
|
||||||
function TEditor.SetBufSize (NewSize : Sw_Word) : Boolean;
|
function TEditor.SetBufSize (NewSize : Sw_Word) : Boolean;
|
||||||
begin
|
begin
|
||||||
ReAllocMem(Buffer, NewSize);
|
{ This function is called on every new key typed on keyboard
|
||||||
BufSize := NewSize;
|
and NewSize is BufLen+1. That is bad idea.
|
||||||
|
Fix: do not allow downsize Buffer,
|
||||||
|
make incremental grow at last by 4k.
|
||||||
|
}
|
||||||
|
if NewSize > BufSize then
|
||||||
|
begin
|
||||||
|
if (NewSize+4096-1) and (not Sw_Word(4095)) > BufSize then
|
||||||
|
begin
|
||||||
|
{Buffer increment to 4k boundary}
|
||||||
|
ReAllocMem(Buffer, (NewSize+4096-1) and (not Sw_Word(4095)) );
|
||||||
|
BufSize := (NewSize+4096-1) and (not Sw_Word(4095));
|
||||||
|
end else
|
||||||
|
begin
|
||||||
|
{branch is taken only if NewSize+4096 wrap around sw_word }
|
||||||
|
ReAllocMem(Buffer, NewSize);
|
||||||
|
BufSize := NewSize;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
SetBufSize := True;
|
SetBufSize := True;
|
||||||
end; { TEditor.SetBufSize }
|
end; { TEditor.SetBufSize }
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user