[fpc-devel] Memory Streams unable to handle reads past 2GB

michael.vancanneyt at wisa.be michael.vancanneyt at wisa.be
Tue Nov 6 09:50:43 CET 2012



On Mon, 5 Nov 2012, Andrew Brunner wrote:

> Same problem with TMemoryStream.Write :-(
>
> On 11/05/2012 10:09 PM, Andrew Brunner wrote:
>> objpas/classes/classesh.inc
>> 
>> TCustomMemoryStream
>>     function Read(var Buffer; Count: LongInt): LongInt; override;
>> 
>> Having Read result declared as LongInt is problematic on 64 bit systems 
>> with large streams.
>> Read result MUST be either PtrInt or Int64 but it cannot be LongInt.

Since you can only read 2GB (Count is a longint) in a single read operation, 
it makes no sense to return a 64-bit result.

Note that the operating system only allows 2Gb reads anyway, even on 64-bit
systems.

Michael.



More information about the fpc-devel mailing list