[fpc-pascal] Pointer to an array of PChar strings
Graeme Geldenhuys
graemeg.lists at gmail.com
Tue Jan 19 15:29:06 CET 2010
Hi,
I'm working with a C library that returns an array of strings. So that is
type PPChar. I C library does the array allocation, but doesn't do the
freeing of the array.
How am I supposed to free an array of PChar strings? I think I need to
improve my iteration too, because I'm moving the pointer of wlst, so I
probably need to make a backup of the original pointer before the iteration.
My code looks as follows:
---------------------------------
var
s: PChar;
wlst: PPChar;
i: integer;
n: integer;
begin
// Returns an array of PChar strings. i = number of elements in array
i := Hunspell_suggest(SpellPtr, wlst, s);
if i > 0 then
writeln(Format(' %d suggestions:', [i]));
for n := 1 to i do
begin
writeln(' ', UTF8Decode(wlst^));
Inc(wlst, SizeOf(Pointer));
end;
end;
---------------------------------
Regards,
- Graeme -
--
fpGUI Toolkit - a cross-platform GUI toolkit using Free Pascal
http://opensoft.homeip.net/fpgui/
More information about the fpc-pascal
mailing list