Procházet zdrojové kódy

* 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 -
florian před 15 roky
rodič
revize
b5167560c3
2 změnil soubory, kde provedl 18 přidání a 19 odebrání
  1. 10 10
      rtl/objpas/classes/classesh.inc
  2. 8 9
      rtl/objpas/classes/streams.inc

+ 10 - 10
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 }

+ 8 - 9
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