|
Last change
on this file was 34, checked in by chronos, 3 years ago |
- Modified: Execute instructions as array of instruction handlers.
- Modified: Optimized some methods call with inline directive.
|
|
File size:
710 bytes
|
| Line | |
|---|
| 1 | unit UMemory;
|
|---|
| 2 |
|
|---|
| 3 | interface
|
|---|
| 4 |
|
|---|
| 5 | uses
|
|---|
| 6 | Classes, SysUtils;
|
|---|
| 7 |
|
|---|
| 8 | type
|
|---|
| 9 | { TMemory }
|
|---|
| 10 |
|
|---|
| 11 | TMemory = class
|
|---|
| 12 | private
|
|---|
| 13 | FSize: Integer;
|
|---|
| 14 | function GetSize: Integer;
|
|---|
| 15 | procedure SetSize(AValue: Integer);
|
|---|
| 16 | public
|
|---|
| 17 | Data: PByte;
|
|---|
| 18 | property Size: Integer read FSize write SetSize;
|
|---|
| 19 | constructor Create;
|
|---|
| 20 | destructor Destroy; override;
|
|---|
| 21 | end;
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 | implementation
|
|---|
| 25 |
|
|---|
| 26 | { TMemory }
|
|---|
| 27 |
|
|---|
| 28 | function TMemory.GetSize: Integer;
|
|---|
| 29 | begin
|
|---|
| 30 | Result := MemSize(Data);
|
|---|
| 31 | end;
|
|---|
| 32 |
|
|---|
| 33 | procedure TMemory.SetSize(AValue: Integer);
|
|---|
| 34 | begin
|
|---|
| 35 | if FSize = AValue then Exit;
|
|---|
| 36 | FSize := AValue;
|
|---|
| 37 | Data := ReAllocMem(Data, AValue);
|
|---|
| 38 | end;
|
|---|
| 39 |
|
|---|
| 40 | constructor TMemory.Create;
|
|---|
| 41 | begin
|
|---|
| 42 | Data := nil;
|
|---|
| 43 | end;
|
|---|
| 44 |
|
|---|
| 45 | destructor TMemory.Destroy;
|
|---|
| 46 | begin
|
|---|
| 47 | Size := 0;
|
|---|
| 48 | inherited;
|
|---|
| 49 | end;
|
|---|
| 50 |
|
|---|
| 51 | end.
|
|---|
| 52 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.