-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlibgit2.buffer.pas
More file actions
62 lines (49 loc) · 957 Bytes
/
libgit2.buffer.pas
File metadata and controls
62 lines (49 loc) · 957 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
unit LibGit2.Buffer;
{$mode objfpc}{$H+}{$modeswitch advancedrecords}
interface
uses
LibGit2.Platform,
LibGit2.StdInt;
type
PGitBuf = ^TGitBuf;
TGitBuf = record
Ptr: Pansichar;
Reserved: size_t;
Size: size_t;
end;
TGitBufHelper = record helper for TGitBuf
procedure Dispose;
function ToString: String;
function Length: size_t;
function IsEmpty: Boolean;
end;
implementation
procedure Libgit2BufferDispose(Buffer: PGitBuf); cdecl; external LibGit2Dll name 'git_buf_dispose';
procedure TGitBufHelper.Dispose;
begin
if Self.Ptr <> nil then
begin
Libgit2BufferDispose(@Self);
Self := Default(TGitBuf);
end;
end;
function TGitBufHelper.ToString: String;
begin
if Ptr = nil then
begin
Result := '';
end
else
begin
Result := StrPas(Ptr);
end;
end;
function TGitBufHelper.Length: size_t;
begin
Result := Size;
end;
function TGitBufHelper.IsEmpty: Boolean;
begin
Result := (Ptr = nil) or (Size = 0);
end;
end.