aboutsummaryrefslogtreecommitdiffstats
path: root/src/base/URingBuffer.pas
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-02-04 17:45:38 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2009-02-04 17:45:38 +0000
commit8fad36f79e14d58fd44ea5146943a2f8019d7a13 (patch)
tree8e228439a17ec25671fab81dd0f0ddad8d2d90a1 /src/base/URingBuffer.pas
parente0337089ed8777756ecfbdfcbc417a5392e90838 (diff)
downloadusdx-8fad36f79e14d58fd44ea5146943a2f8019d7a13.tar.gz
usdx-8fad36f79e14d58fd44ea5146943a2f8019d7a13.tar.xz
usdx-8fad36f79e14d58fd44ea5146943a2f8019d7a13.zip
- PChar replaced by PByteArray (for byte buffers) or PAnsiString (for zero-terminated strings)
- TRingBuffer.Size()/.Available() added git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1584 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--src/base/URingBuffer.pas24
1 files changed, 18 insertions, 6 deletions
diff --git a/src/base/URingBuffer.pas b/src/base/URingBuffer.pas
index 515d0efb..684c13ee 100644
--- a/src/base/URingBuffer.pas
+++ b/src/base/URingBuffer.pas
@@ -39,7 +39,7 @@ uses
type
TRingBuffer = class
private
- RingBuffer: PChar;
+ RingBuffer: PByteArray;
BufferCount: integer;
BufferSize: integer;
WritePos: integer;
@@ -47,8 +47,10 @@ type
public
constructor Create(Size: integer);
destructor Destroy; override;
- function Read(Buffer: PChar; Count: integer): integer;
- function Write(Buffer: PChar; Count: integer): integer;
+ function Read(Buffer: PByteArray; Count: integer): integer;
+ function Write(Buffer: PByteArray; Count: integer): integer;
+ function Size(): integer;
+ function Available(): integer;
procedure Flush();
end;
@@ -71,7 +73,7 @@ begin
FreeMem(RingBuffer);
end;
-function TRingBuffer.Read(Buffer: PChar; Count: integer): integer;
+function TRingBuffer.Read(Buffer: PByteArray; Count: integer): integer;
var
PartCount: integer;
begin
@@ -106,7 +108,7 @@ begin
Result := Count;
end;
-function TRingBuffer.Write(Buffer: PChar; Count: integer): integer;
+function TRingBuffer.Write(Buffer: PByteArray; Count: integer): integer;
var
PartCount: integer;
begin
@@ -143,6 +145,16 @@ begin
Result := Count;
end;
+function TRingBuffer.Available(): integer;
+begin
+ Result := BufferCount;
+end;
+
+function TRingBuffer.Size(): integer;
+begin
+ Result := BufferSize;
+end;
+
procedure TRingBuffer.Flush();
begin
ReadPos := 0;
@@ -150,4 +162,4 @@ begin
BufferCount := 0;
end;
-end. \ No newline at end of file
+end.