mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-17 03:59:13 +02:00
Contra intuitive: TEditor.SetBufSize should not change BufSize at all
This commit is contained in:
parent
4b4f910289
commit
86486f9c46
@ -3020,26 +3020,7 @@ end; { TEditor.SetBufLen }
|
|||||||
|
|
||||||
function TEditor.SetBufSize (NewSize : Sw_Word) : Boolean;
|
function TEditor.SetBufSize (NewSize : Sw_Word) : Boolean;
|
||||||
begin
|
begin
|
||||||
{ This function is called on every new key typed on keyboard
|
if BufSize>=NewSize then SetBufSize:=true else SetBufSize:=false;
|
||||||
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;
|
|
||||||
end; { TEditor.SetBufSize }
|
end; { TEditor.SetBufSize }
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user