summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--core/linux.c11
-rw-r--r--core/macos.c11
-rw-r--r--core/windows.c9
3 files changed, 14 insertions, 17 deletions
diff --git a/core/linux.c b/core/linux.c
index da96ecb49..2f8d9d832 100644
--- a/core/linux.c
+++ b/core/linux.c
@@ -83,18 +83,17 @@ const char *system_default_directory(void)
const char *system_default_filename(void)
{
- static char *filename = NULL;
- if (!filename) {
+ static const char *path = NULL;
+ if (!path) {
const char *user = getenv("LOGNAME");
if (same_string(user, ""))
user = "username";
- filename = calloc(strlen(user) + 5, 1);
+ char *filename = calloc(strlen(user) + 5, 1);
strcat(filename, user);
strcat(filename, ".xml");
- }
- static const char *path = NULL;
- if (!path)
path = system_default_path_append(filename);
+ free(filename);
+ }
return path;
}
diff --git a/core/macos.c b/core/macos.c
index b16225c78..37bbd5d25 100644
--- a/core/macos.c
+++ b/core/macos.c
@@ -81,18 +81,17 @@ const char *system_default_directory(void)
const char *system_default_filename(void)
{
- static char *filename = NULL;
- if (!filename) {
+ static const char *path = NULL;
+ if (!path) {
const char *user = getenv("LOGNAME");
if (same_string(user, ""))
user = "username";
- filename = calloc(strlen(user) + 5, 1);
+ char *filename = calloc(strlen(user) + 5, 1);
strcat(filename, user);
strcat(filename, ".xml");
- }
- static const char *path = NULL;
- if (!path)
path = system_default_path_append(filename);
+ free(filename);
+ }
return path;
}
diff --git a/core/windows.c b/core/windows.c
index 029c3516e..f0b9eb22c 100644
--- a/core/windows.c
+++ b/core/windows.c
@@ -103,17 +103,16 @@ const char *system_default_directory(void)
*/
const char *system_default_filename(void)
{
- static wchar_t filename[UNLEN + 5] = { 0 };
- if (!*filename) {
+ static const char *path = NULL;
+ if (!path) {
wchar_t username[UNLEN + 1] = { 0 };
DWORD username_len = UNLEN + 1;
GetUserNameW(username, &username_len);
+ wchar_t filename[UNLEN + 5] = { 0 };
wcscat(filename, username);
wcscat(filename, L".xml");
- }
- static const char *path = NULL;
- if (!path)
path = system_default_path_append(filename);
+ }
return path;
}