I have this piece of code.
The BufferAddress was initially of PByteArray type.
However, PByteArray is limited to 32768 elements but I need more than than.
I don’t need at run time what is the maximum limit, so I defined TLargeArrayOfBytes from 0 to 2GB. There is a nicer way to do it?
function TBufferedStream.Read(VAR aBuffer; Count: Integer): Longint;
TYPE
TLargeArrayOfBytes = array[0..2000000000] of Byte;
PArrayOfBytes = ^TLargeArrayOfBytes;
VAR
BufferAddress: PArrayOfBytes; // it was PByteArray
begin
...
{ Then refill buffer... }
FillReadBuffer;
{ ...and continue reading }
BufferAddress:= @TLargeArrayOfBytes(aBuffer);
Result:= Result+ ReadFromBuffer(BufferAddress[Result], Count- Result); { Read from RAM buffer }
end;
Delphi 7
I don’t see anything wrong in your definition, the only suggestion is you can use the
MaxIntconst.or maybe the
SysUtils.TBytestype