On Fri, 10 May 2019 at 16:46, Józef Kucia joseph.kucia@gmail.com wrote:
+const char *vkd3d_get_program_name(void) +{ +#ifdef _GNU_SOURCE
- char *name;
- if ((name = strrchr(program_invocation_name, '/')))
- {
const char *path = realpath("/proc/self/exe", NULL);/* Try to strip command line arguments. */if (path && !strncmp(path, program_invocation_name, strlen(path))){const char *p = strrchr(path, '/');if (p)return p + 1;}return name + 1;- }
- if ((name = strrchr(program_invocation_name, '\')))
return name + 1;- return program_invocation_name;
+#else
- return NULL;
+#endif +}
realpath() allocates memory.