> On Jun 2, 2019, at 2:48 PM, Michael Van Canneyt <mich...@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 _______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal