[fpc-pascal] PChar -> AnsiString -> PChar = memory leak?
Henry Vermaak
henry.vermaak at gmail.com
Thu Oct 29 15:02:34 CET 2009
2009/10/29 Graeme Geldenhuys <graemeg.lists at gmail.com>:
> On 29/10/2009, Mattias Gaertner <nc-gaertnma at netcologne.de> wrote:
>>
>>
>> Text:=strnew(PChar(s));
>
> You read my mind. I was going to ask if it's ok to cast a PString to a PChar.
>
> Trying what you suggested, I get the following compiler error.
>
> project1.lpr(20,11) Error: Incompatible types: got "PString" expected "PChar"
This is probably dependant on compiler modes?
You may have to do it like this:
StrDispose(Text);
Text := StrAlloc(length(s) + 1);
StrPCopy(Text, s);
Henry
More information about the fpc-pascal
mailing list