[fpc-pascal] TStringList/pchar question
Ryan Joseph
ryan at thealchemistguild.com
Sun Jun 2 20:58:52 CEST 2019
> On Jun 2, 2019, at 2:48 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
>
>> I just learned that pchar is not ref counted like I used to think so I’m curious why this code doesn’t fail. Shouldn’t this crash because I free TStringList and then access GetText?
>
> You're first doing gettext and then freeing. So this is OK.
I thought pchar was ref counted so by calling GetText I was retaining ownership but GetText is allocating a new string (https://www.freepascal.org/docs-html/rtl/classes/tstrings.gettext.html). Sorry I didn’t read the documentation because I made a bad assumption about ref counting. Thanks.
Regards,
Ryan Joseph
More information about the fpc-pascal
mailing list