mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-10-24 22:32:55 +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
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Classes;
|
Classes, Math;
|
||||||
|
|
||||||
type
|
type
|
||||||
PLCLMemManagerItem = ^TLCLMemManagerItem;
|
PLCLMemManagerItem = ^TLCLMemManagerItem;
|
||||||
@ -92,6 +92,8 @@ type
|
|||||||
{ TExtMemoryStream }
|
{ TExtMemoryStream }
|
||||||
|
|
||||||
TExtMemoryStream = class(TMemoryStream)
|
TExtMemoryStream = class(TMemoryStream)
|
||||||
|
protected
|
||||||
|
function Realloc(var NewCapacity: Longint): Pointer; override;
|
||||||
public
|
public
|
||||||
property Capacity: Longint read FCapacity write SetCapacity;
|
property Capacity: Longint read FCapacity write SetCapacity;
|
||||||
end;
|
end;
|
||||||
@ -267,5 +269,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
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.
|
end.
|
||||||
|
|
||||||
|
|||||||
@ -1933,9 +1933,12 @@ procedure LRSObjectBinaryToText(Input, Output: TStream);
|
|||||||
|
|
||||||
procedure ProcessBinary;
|
procedure ProcessBinary;
|
||||||
var
|
var
|
||||||
ToDo, DoNow, i: LongInt;
|
ToDo, DoNow, StartPos, i: LongInt;
|
||||||
lbuf: array[0..31] of Byte;
|
lbuf: array[0..31] of Byte;
|
||||||
s: String;
|
s: String;
|
||||||
|
p: pchar;
|
||||||
|
const
|
||||||
|
HexDigits: array[0..$F] of char = '0123456789ABCDEF';
|
||||||
begin
|
begin
|
||||||
ToDo := ReadLRSCardinal(Input);
|
ToDo := ReadLRSCardinal(Input);
|
||||||
OutLn('{');
|
OutLn('{');
|
||||||
@ -1944,9 +1947,16 @@ procedure LRSObjectBinaryToText(Input, Output: TStream);
|
|||||||
if DoNow > 32 then DoNow := 32;
|
if DoNow > 32 then DoNow := 32;
|
||||||
Dec(ToDo, DoNow);
|
Dec(ToDo, DoNow);
|
||||||
s := Indent + ' ';
|
s := Indent + ' ';
|
||||||
|
StartPos := length(s);
|
||||||
Input.Read(lbuf, DoNow);
|
Input.Read(lbuf, DoNow);
|
||||||
for i := 0 to DoNow - 1 do
|
setlength(s, StartPos+DoNow*2);
|
||||||
s := s + IntToHex(lbuf[i], 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);
|
OutLn(s);
|
||||||
end;
|
end;
|
||||||
OutStr(indent);
|
OutStr(indent);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user