[fpc-devel] TVarRec.VAnsiString memory leak? - solved
petr.kristan at epos.cz
petr.kristan at epos.cz
Fri Mar 28 14:09:13 CET 2008
On Fri, Mar 28, 2008 at 10:17:01AM +0100, Michael Van Canneyt wrote:
> This is a correct way:
>
> program str;
>
> uses
> heaptrc;
>
> var
> s,t: ansistring;
> vr: TVarRec;
>
> begin
> SetString(s, 'xxx', 3); //ok
> vr.VType := vtAnsiString;
> t:='yyy';
> vr.VAnsiString:=Pointer(T);
> end.
>
Final solution is not to use VAnsiString because reference counting
little confusing. My problem was to fill "array of const" with strings.
And these strings must be somewere stored.
Then i use
vr.VPChar = StrNew(PChar(s));
...
StrDispose(vr.VPChar);
Petr
--
Ing. Petr Kristan
.
EPOS PRO s.r.o., Bozeny Nemcove 2625, 530 02 Pardubice
tel: +420 466335223 Czech Republic (Eastern Europe)
fax: +420 466510709
More information about the fpc-devel
mailing list