Die Definition des Stringarrays in C ist folgendermassen
Original aus der strarray.h
Code: Alles auswählen
/** Array of strings */
typedef struct git_strarray {
char **strings;
size_t count;
} git_strarray;
Code: Alles auswählen
(** Array of strings *)
type
git_strarray = record
strings: PPAnsiChar;
Count: size_t;
end;
Pgit_strarray = ^git_strarray;
meine Umsetzung mittels
Code: Alles auswählen
procedure StringListToGitStrArray(const List: TStringList; out Arr: git_strarray);
var
i: Integer;
S: AnsiString;
Len: SizeUInt;
P: PPAnsiChar;
begin
Arr.Count := List.Count;
if Arr.Count = 0 then
begin
Arr.strings := nil;
Exit;
end;
GetMem(Arr.strings, Arr.Count * SizeOf(PAnsiChar));
P := Arr.strings;
for i := 0 to Arr.Count - 1 do
begin
S := UTF8Encode(List[i])+#0; // für Git besser
Len := Length(S);
GetMem(P^, Len);
if Len > 0 then
Move(Pointer(S)^, P^, Len);
Inc(P);
end;
end;
BTW: Lazarus/FPC main zeigt mir soger die Stellen im C-Code an, da ich die Sourcen von libgit2 am Rechner habe.