mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-23 17:01:35 +02:00
LCL: improved stream of large objects (issue #7270)
git-svn-id: trunk@10321 -
This commit is contained in:
parent
90251b1bdc
commit
69391d2648
@ -27,7 +27,7 @@ unit LCLMemManager;
|
||||
interface
|
||||
|
||||
uses
|
||||
Classes;
|
||||
Classes, Math;
|
||||
|
||||
type
|
||||
PLCLMemManagerItem = ^TLCLMemManagerItem;
|
||||
@ -92,6 +92,8 @@ type
|
||||
{ TExtMemoryStream }
|
||||
|
||||
TExtMemoryStream = class(TMemoryStream)
|
||||
protected
|
||||
function Realloc(var NewCapacity: Longint): Pointer; override;
|
||||
public
|
||||
property Capacity: Longint read FCapacity write SetCapacity;
|
||||
end;
|
||||
@ -267,5 +269,15 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
{ TExtMemoryStream }
|
||||
|
||||
function TExtMemoryStream.Realloc(var NewCapacity: LongInt): Pointer;
|
||||
begin
|
||||
// if we are growing, grow at least a quarter
|
||||
if (NewCapacity>Capacity) then
|
||||
NewCapacity := Max(NewCapacity, Capacity + Capacity div 4);
|
||||
Result:=inherited Realloc(NewCapacity);
|
||||
end;
|
||||
|
||||
end.
|
||||
|
||||
|
@ -1933,9 +1933,12 @@ procedure LRSObjectBinaryToText(Input, Output: TStream);
|
||||
|
||||
procedure ProcessBinary;
|
||||
var
|
||||
ToDo, DoNow, i: LongInt;
|
||||
ToDo, DoNow, StartPos, i: LongInt;
|
||||
lbuf: array[0..31] of Byte;
|
||||
s: String;
|
||||
p: pchar;
|
||||
const
|
||||
HexDigits: array[0..$F] of char = '0123456789ABCDEF';
|
||||
begin
|
||||
ToDo := ReadLRSCardinal(Input);
|
||||
OutLn('{');
|
||||
@ -1944,9 +1947,16 @@ procedure LRSObjectBinaryToText(Input, Output: TStream);
|
||||
if DoNow > 32 then DoNow := 32;
|
||||
Dec(ToDo, DoNow);
|
||||
s := Indent + ' ';
|
||||
StartPos := length(s);
|
||||
Input.Read(lbuf, DoNow);
|
||||
for i := 0 to DoNow - 1 do
|
||||
s := s + IntToHex(lbuf[i], 2);
|
||||
setlength(s, StartPos+DoNow*2);
|
||||
p := @s[StartPos];
|
||||
for i := 0 to DoNow - 1 do begin
|
||||
inc(p);
|
||||
p^ := HexDigits[(lbuf[i] shr 4) and $F];
|
||||
inc(p);
|
||||
p^ := HexDigits[lbuf[i] and $F];
|
||||
end;
|
||||
OutLn(s);
|
||||
end;
|
||||
OutStr(indent);
|
||||
|
Loading…
Reference in New Issue
Block a user