From b5167560c3d8fc4f1c6a2ce54806f27c947b854d Mon Sep 17 00:00:00 2001 From: florian Date: Fri, 1 Jan 2010 21:05:18 +0000 Subject: [PATCH] * T*MemoryStream now uses PtrInt for sizes and positions so it can be bigger than 2 GB on 64 Bit systems, resolves #15313 git-svn-id: trunk@14513 - --- rtl/objpas/classes/classesh.inc | 20 ++++++++++---------- rtl/objpas/classes/streams.inc | 17 ++++++++--------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/rtl/objpas/classes/classesh.inc b/rtl/objpas/classes/classesh.inc index fc6eec7737..c2907d98be 100644 --- a/rtl/objpas/classes/classesh.inc +++ b/rtl/objpas/classes/classesh.inc @@ -866,13 +866,13 @@ type TCustomMemoryStream = class(TStream) private FMemory: Pointer; - FSize, FPosition: Longint; + FSize, FPosition: PtrInt; protected - procedure SetPointer(Ptr: Pointer; ASize: Longint); + procedure SetPointer(Ptr: Pointer; ASize: PtrInt); public Function GetSize : Int64; Override; - function Read(var Buffer; Count: Longint): Longint; override; - function Seek(Offset: Longint; Origin: Word): Longint; override; + function Read(var Buffer; Count: PtrInt): PtrInt; override; + function Seek(Offset: PtrInt; Origin: Word): PtrInt; override; procedure SaveToStream(Stream: TStream); procedure SaveToFile(const FileName: string); property Memory: Pointer read FMemory; @@ -882,18 +882,18 @@ type TMemoryStream = class(TCustomMemoryStream) private - FCapacity: Longint; - procedure SetCapacity(NewCapacity: Longint); + FCapacity: PtrInt; + procedure SetCapacity(NewCapacity: PtrInt); protected - function Realloc(var NewCapacity: Longint): Pointer; virtual; - property Capacity: Longint read FCapacity write SetCapacity; + function Realloc(var NewCapacity: PtrInt): Pointer; virtual; + property Capacity: PtrInt read FCapacity write SetCapacity; public destructor Destroy; override; procedure Clear; procedure LoadFromStream(Stream: TStream); procedure LoadFromFile(const FileName: string); - procedure SetSize(NewSize: Longint); override; - function Write(const Buffer; Count: Longint): Longint; override; + procedure SetSize(NewSize: PtrInt); override; + function Write(const Buffer; Count: PtrInt): PtrInt; override; end; { TStringStream } diff --git a/rtl/objpas/classes/streams.inc b/rtl/objpas/classes/streams.inc index 12ff0626d9..e4a1a5e535 100644 --- a/rtl/objpas/classes/streams.inc +++ b/rtl/objpas/classes/streams.inc @@ -500,7 +500,7 @@ end; {* TCustomMemoryStream *} {****************************************************************************} -procedure TCustomMemoryStream.SetPointer(Ptr: Pointer; ASize: Longint); +procedure TCustomMemoryStream.SetPointer(Ptr: Pointer; ASize: PtrInt); begin FMemory:=Ptr; @@ -515,7 +515,7 @@ begin end; -function TCustomMemoryStream.Read(var Buffer; Count: Longint): Longint; +function TCustomMemoryStream.Read(var Buffer; Count: PtrInt): PtrInt; begin Result:=0; @@ -529,7 +529,7 @@ begin end; -function TCustomMemoryStream.Seek(Offset: Longint; Origin: Word): Longint; +function TCustomMemoryStream.Seek(Offset: PtrInt; Origin: Word): PtrInt; begin Case Origin of @@ -573,7 +573,7 @@ end; Const TMSGrow = 4096; { Use 4k blocks. } -procedure TMemoryStream.SetCapacity(NewCapacity: Longint); +procedure TMemoryStream.SetCapacity(NewCapacity: PtrInt); begin SetPointer (Realloc(NewCapacity),Fsize); @@ -581,10 +581,9 @@ begin end; -function TMemoryStream.Realloc(var NewCapacity: Longint): Pointer; +function TMemoryStream.Realloc(var NewCapacity: PtrInt): Pointer; begin - If NewCapacity<0 Then NewCapacity:=0 else @@ -647,7 +646,7 @@ begin end; -procedure TMemoryStream.SetSize(NewSize: Longint); +procedure TMemoryStream.SetSize(NewSize: PtrInt); begin SetCapacity (NewSize); @@ -656,9 +655,9 @@ begin FPosition:=FSize; end; -function TMemoryStream.Write(const Buffer; Count: Longint): Longint; +function TMemoryStream.Write(const Buffer; Count: PtrInt): PtrInt; -Var NewPos : Longint; +Var NewPos : PtrInt; begin If (Count=0) or (FPosition<0) then