Changeset 59 for branches/ByteArray/Devices/Memory.pas
- Timestamp:
- Nov 25, 2023, 11:47:52 PM (12 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/ByteArray/Devices/Memory.pas
r56 r59 16 16 function GetSize: Integer; 17 17 procedure SetSize(AValue: Integer); 18 procedure CheckGrow(Address: Integer); 18 19 public 19 20 Position: Integer; 21 Grow: Boolean; 20 22 procedure Assign(Source: TMemory); 21 23 function Read(Address: TBigInt; ASize: TBigIntSize): TBigInt; … … 28 30 procedure SetChannel(Channel: TChannel); override; 29 31 procedure SaveToFile(FileName: string); 30 procedure Clean; 32 procedure FillZero; 33 procedure Clear; 31 34 property Size: Integer read FSize write SetSize; 32 35 destructor Destroy; override; … … 50 53 FSize := AValue; 51 54 FData := ReAllocMem(FData, AValue); 55 end; 56 57 procedure TMemory.CheckGrow(Address: Integer); 58 begin 59 if Grow and (Size < Address) then Size := Address; 52 60 end; 53 61 … … 90 98 procedure TMemory.WritePos(ASize: Byte; Value: TBigInt); 91 99 begin 100 CheckGrow(Position + ASize); 92 101 Write(Position, ASize, Value); 93 102 Inc(Position, ASize); … … 98 107 I: Integer; 99 108 begin 109 CheckGrow(Position + Length(Value)); 100 110 if Length(Value) > 0 then begin 101 111 if Position + Length(Value) > FSize then Size := Position + Length(Value); … … 108 118 procedure TMemory.WriteMemoryPos(Memory: TMemory); 109 119 begin 120 CheckGrow(Position + Memory.Size); 110 121 if Memory.Size > 0 then begin 111 122 if Position + Memory.Size > FSize then Size := Position + Memory.Size; … … 126 137 end; 127 138 128 procedure TMemory. Clean;139 procedure TMemory.FillZero; 129 140 begin 130 141 FillChar(FData^, FSize, 0); 142 end; 143 144 procedure TMemory.Clear; 145 begin 146 Size := 0; 147 Position := 0; 131 148 end; 132 149
Note:
See TracChangeset
for help on using the changeset viewer.