Which strings ought I to free in C on my own, using free()
¹?
My state of knowledge:
char a[256];
: nochar *a = "abcdefg";
: nochar *a = malloc(15L);
: yesgetenv()
: no¹ or LocalFree()
/GlobalFree()
/VirtualFree()
² in particular by GetCommandLineW()
This will always be mentioned in the documentation for any API you use that returns strings (or other data larger than a single simple value such as an integer).
Yes, this means you have to read the documentation thoroughly for all such API functions, in order to keep track and not leak memory.