From d7c2eba4fd3e4879e9a9ab2b4a7ffc04ae9d2174 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 30 Jan 2020 20:05:44 +0100 Subject: [PATCH] Simplify get_temp_directory_alloc --- retroarch.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/retroarch.c b/retroarch.c index 98a2f9ed81..539930e7eb 100644 --- a/retroarch.c +++ b/retroarch.c @@ -10832,13 +10832,13 @@ static void clear_controller_port_map(void) static char *get_temp_directory_alloc(void) { + const char *src; char *path = NULL; #ifdef _WIN32 #ifdef LEGACY_WIN32 DWORD path_length = GetTempPath(0, NULL) + 1; - path = (char*)malloc(path_length * sizeof(char)); - if (!path) + if (!(path = (char*)malloc(path_length * sizeof(char)))) return NULL; path[path_length - 1] = 0; @@ -10856,17 +10856,16 @@ static char *get_temp_directory_alloc(void) path = utf16_to_utf8_string_alloc(wide_str); free(wide_str); #endif -#elif defined ANDROID - { - settings_t *settings = configuration_settings; - path = strcpy_alloc_force(settings->paths.directory_libretro); - } +#else +#if defined ANDROID + src = configuration_settings->paths.directory_libretro; #else if (getenv("TMPDIR")) - path = strcpy_alloc_force(getenv("TMPDIR")); - else - path = strcpy_alloc_force("/tmp"); - + src = getenv("TMPDIR"); + else + src = "/tmp"; +#endif + path = strcpy_alloc_force(src); #endif return path; }