On Sun, 2 Jun 2019, Ryan Joseph 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.
strings := TStringList.Create; strings.LoadFromFile(vertexShaderPath); vertexShaderSource := strings.GetText; strings.Free; glShaderSource(vertexShaderID, 1, @vertexShaderSource, nil);
You'll get a memory leak, unless you're freeing vertexShaderSource further on.See also https://www.freepascal.org/docs-html/rtl/classes/tstrings.gettext.html
Michael.
_______________________________________________ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal