mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-22 08:29:29 +02:00
* Patch from Vincent Snijders to grow memory stream by a quarter of its size
git-svn-id: trunk@5581 -
This commit is contained in:
parent
9d3c23bb80
commit
2eda10c74c
@ -535,11 +535,17 @@ end;
|
||||
function TMemoryStream.Realloc(var NewCapacity: Longint): Pointer;
|
||||
|
||||
begin
|
||||
// round off to block size.
|
||||
|
||||
If NewCapacity<0 Then
|
||||
NewCapacity:=0
|
||||
else
|
||||
NewCapacity := (NewCapacity + (TMSGrow-1)) and not (TMSGROW-1);
|
||||
begin
|
||||
// if growing, grow at least a quarter
|
||||
if (NewCapacity>FCapacity) and (NewCapacity < (5*FCapacity) div 4) then
|
||||
NewCapacity := (5*FCapacity) div 4;
|
||||
// round off to block size.
|
||||
NewCapacity := (NewCapacity + (TMSGrow-1)) and not (TMSGROW-1);
|
||||
end;
|
||||
// Only now check !
|
||||
If NewCapacity=FCapacity then
|
||||
Result:=FMemory
|
||||
|
Loading…
Reference in New Issue
Block a user