Merge commit '852f2a6343518919e5ca8d3c1bbcab9f493e3cd8'

This commit is contained in:
2024-01-17 17:02:59 +01:00
1244 changed files with 50102 additions and 28146 deletions

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -40,8 +40,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
if (path) {
size_t pathlen = SDL_strlen(path) + 2;
char *fullpath = (char *)SDL_malloc(pathlen);
if (fullpath == NULL) {
SDL_OutOfMemory();
if (!fullpath) {
return NULL;
}
SDL_snprintf(fullpath, pathlen, "%s/", path);

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -52,9 +52,7 @@ char *SDL_GetBasePath(void)
if (base) {
const size_t len = SDL_strlen(base) + 2;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
} else {
if (retval != NULL) {
SDL_snprintf(retval, len, "%s/", base);
}
}
@ -105,9 +103,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
if (base) {
const size_t len = SDL_strlen(base) + SDL_strlen(org) + SDL_strlen(app) + 4;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
} else {
if (retval != NULL) {
char *ptr;
if (*org) {
SDL_snprintf(retval, len, "%s/%s/%s/", base, org, app);
@ -152,13 +148,7 @@ char *SDL_GetUserFolder(SDL_Folder folder)
SDL_SetError("No $HOME environment variable available");
}
retval = SDL_strdup(base);
if (!retval) {
SDL_OutOfMemory();
}
return retval;
return SDL_strdup(base);
case SDL_FOLDER_DESKTOP:
dir = NSDesktopDirectory;
@ -221,7 +211,6 @@ char *SDL_GetUserFolder(SDL_Folder folder)
retval = SDL_strdup(base);
if (retval == NULL) {
SDL_OutOfMemory();
return NULL;
}

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -42,18 +42,17 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
len = SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
if (!retval) {
return NULL;
}
@ -86,7 +85,6 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *SDL_GetUserFolder(SDL_Folder folder)
{
const char *home = NULL;
char *retval;
if (folder != SDL_FOLDER_HOME) {
SDL_SetError("Emscripten only supports the home folder");
@ -99,13 +97,7 @@ char *SDL_GetUserFolder(SDL_Folder folder)
return NULL;
}
retval = SDL_strdup(home);
if (!retval) {
SDL_OutOfMemory();
}
return retval;
return SDL_strdup(home);
}
#endif /* SDL_FILESYSTEM_EMSCRIPTEN */

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -18,7 +18,7 @@
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "../../SDL_internal.h"
#include "SDL_internal.h"
#ifdef SDL_FILESYSTEM_XBOX
@ -26,9 +26,9 @@
/* System dependent filesystem routines */
#include "../../core/windows/SDL_windows.h"
#include "SDL_hints.h"
#include "SDL_system.h"
#include "SDL_filesystem.h"
#include <SDL3/SDL_hints.h>
#include <SDL3/SDL_system.h>
#include <SDL3/SDL_filesystem.h>
#include <XGameSaveFiles.h>
char *
@ -44,9 +44,8 @@ SDL_GetBasePath(void)
while (SDL_TRUE) {
void *ptr = SDL_realloc(path, buflen * sizeof(CHAR));
if (ptr == NULL) {
if (!ptr) {
SDL_free(path);
SDL_OutOfMemory();
return NULL;
}
@ -90,13 +89,13 @@ SDL_GetPrefPath(const char *org, const char *app)
HRESULT result;
const char *csid = SDL_GetHint("SDL_GDK_SERVICE_CONFIGURATION_ID");
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
/* This should be set before calling SDL_GetPrefPath! */
if (csid == NULL) {
if (!csid) {
SDL_LogWarn(SDL_LOG_CATEGORY_SYSTEM, "Set SDL_GDK_SERVICE_CONFIGURATION_ID before calling SDL_GetPrefPath!");
return SDL_strdup("T:\\");
}

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -51,8 +51,7 @@ char *SDL_GetBasePath(void)
const size_t len = SDL_strlen(str);
char *retval = (char *) SDL_malloc(len + 2);
if (retval == NULL) {
SDL_OutOfMemory();
if (!retval) {
return NULL;
}
@ -70,11 +69,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
const char *append = "/config/settings/";
size_t len = SDL_strlen(home);
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
@ -83,9 +82,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
}
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
char *retval = (char *) SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
} else {
if (retval) {
if (*org) {
SDL_snprintf(retval, len, "%s%s%s/%s/", home, append, org, app);
} else {
@ -110,25 +107,17 @@ char *SDL_GetUserFolder(SDL_Folder folder)
switch (folder) {
case SDL_FOLDER_HOME:
retval = SDL_strdup(home);
if (!retval) {
SDL_OutOfMemory();
}
return retval;
return SDL_strdup(home);
/* TODO: Is Haiku's desktop folder always ~/Desktop/ ? */
case SDL_FOLDER_DESKTOP:
retval = (char *) SDL_malloc(SDL_strlen(home) + 10);
if (!retval) {
SDL_OutOfMemory();
if (retval) {
SDL_strlcpy(retval, home, SDL_strlen(home) + 10);
SDL_strlcat(retval, "/Desktop/", SDL_strlen(home) + 10);
}
SDL_strlcpy(retval, home, SDL_strlen(home) + 10);
SDL_strlcat(retval, "/Desktop/", SDL_strlen(home) + 10);
return retval;
case SDL_FOLDER_DOCUMENTS:

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -41,13 +41,13 @@ char *SDL_GetBasePath(void)
char *SDL_GetPrefPath(const char *org, const char *app)
{
char *pref_path = NULL;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
pref_path = MakePrefPath(app);
if (pref_path == NULL) {
if (!pref_path) {
return NULL;
}
@ -70,7 +70,6 @@ static char *MakePrefPath(const char *app)
{
char *pref_path;
if (SDL_asprintf(&pref_path, "sdmc:/3ds/%s/", app) < 0) {
SDL_OutOfMemory();
return NULL;
}
return pref_path;

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -79,11 +79,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -47,11 +47,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *retval = NULL;
size_t len;
char *base = SDL_GetBasePath();
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -34,21 +34,20 @@ static char *SDL_unixify_std(const char *ro_path, char *buffer, size_t buf_len,
{
const char *const in_buf = buffer; /* = NULL if we allocate the buffer. */
if (buffer == NULL) {
if (!buffer) {
/* This matches the logic in __unixify, with an additional byte for the
* extra path separator.
*/
buf_len = SDL_strlen(ro_path) + 14 + 1;
buffer = SDL_malloc(buf_len);
if (buffer == NULL) {
SDL_OutOfMemory();
if (!buffer) {
return NULL;
}
}
if (!__unixify_std(ro_path, buffer, buf_len, filetype)) {
if (in_buf == NULL) {
if (!in_buf) {
SDL_free(buffer);
}
@ -88,8 +87,7 @@ static char *canonicalisePath(const char *path, const char *pathVar)
regs.r[5] = 1 - regs.r[5];
buf = SDL_malloc(regs.r[5]);
if (buf == NULL) {
SDL_OutOfMemory();
if (!buf) {
return NULL;
}
regs.r[2] = (int)buf;
@ -117,7 +115,7 @@ static _kernel_oserror *createDirectoryRecursive(char *path)
*ptr = '\0';
error = _kernel_swi(OS_File, &regs, &regs);
*ptr = '.';
if (error != NULL) {
if (error) {
return error;
}
}
@ -137,13 +135,13 @@ char *SDL_GetBasePath(void)
}
canon = canonicalisePath((const char *)regs.r[0], "Run$Path");
if (canon == NULL) {
if (!canon) {
return NULL;
}
/* chop off filename. */
ptr = SDL_strrchr(canon, '.');
if (ptr != NULL) {
if (ptr) {
*ptr = '\0';
}
@ -158,23 +156,22 @@ char *SDL_GetPrefPath(const char *org, const char *app)
size_t len;
_kernel_oserror *error;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
canon = canonicalisePath("<Choices$Write>", "Run$Path");
if (canon == NULL) {
if (!canon) {
return NULL;
}
len = SDL_strlen(canon) + SDL_strlen(org) + SDL_strlen(app) + 4;
dir = (char *)SDL_malloc(len);
if (dir == NULL) {
SDL_OutOfMemory();
if (!dir) {
SDL_free(canon);
return NULL;
}
@ -188,7 +185,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
SDL_free(canon);
error = createDirectoryRecursive(dir);
if (error != NULL) {
if (error) {
SDL_SetError("Couldn't create directory: %s", error->errmess);
SDL_free(dir);
return NULL;

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -47,8 +47,7 @@ static char *readSymLink(const char *path)
while (1) {
char *ptr = (char *)SDL_realloc(retval, (size_t)len);
if (ptr == NULL) {
SDL_OutOfMemory();
if (!ptr) {
break;
}
@ -78,14 +77,13 @@ static char *search_path_for_binary(const char *bin)
char *start = envr;
char *ptr;
if (envr == NULL) {
if (!envr) {
SDL_SetError("No $PATH set");
return NULL;
}
envr = SDL_strdup(envr);
if (envr == NULL) {
SDL_OutOfMemory();
if (!envr) {
return NULL;
}
@ -110,7 +108,7 @@ static char *search_path_for_binary(const char *bin)
}
}
start = ptr + 1; /* start points to beginning of next element. */
} while (ptr != NULL);
} while (ptr);
SDL_free(envr);
SDL_free(exe);
@ -130,8 +128,7 @@ char *SDL_GetBasePath(void)
const int mib[] = { CTL_KERN, KERN_PROC, KERN_PROC_PATHNAME, -1 };
if (sysctl(mib, SDL_arraysize(mib), fullpath, &buflen, NULL, 0) != -1) {
retval = SDL_strdup(fullpath);
if (retval == NULL) {
SDL_OutOfMemory();
if (!retval) {
return NULL;
}
}
@ -144,15 +141,13 @@ char *SDL_GetBasePath(void)
if (sysctl(mib, 4, NULL, &len, NULL, 0) != -1) {
char *exe, *pwddst;
char *realpathbuf = (char *)SDL_malloc(PATH_MAX + 1);
if (realpathbuf == NULL) {
SDL_OutOfMemory();
if (!realpathbuf) {
return NULL;
}
cmdline = SDL_malloc(len);
if (cmdline == NULL) {
if (!cmdline) {
SDL_free(realpathbuf);
SDL_OutOfMemory();
return NULL;
}
@ -172,7 +167,7 @@ char *SDL_GetBasePath(void)
}
if (exe) {
if (pwddst == NULL) {
if (!pwddst) {
if (realpath(exe, realpathbuf) != NULL) {
retval = realpathbuf;
}
@ -188,7 +183,7 @@ char *SDL_GetBasePath(void)
}
}
if (retval == NULL) {
if (!retval) {
SDL_free(realpathbuf);
}
@ -197,7 +192,7 @@ char *SDL_GetBasePath(void)
#endif
/* is a Linux-style /proc filesystem available? */
if (retval == NULL && (access("/proc", F_OK) == 0)) {
if (!retval && (access("/proc", F_OK) == 0)) {
/* !!! FIXME: after 2.0.6 ships, let's delete this code and just
use the /proc/%llu version. There's no reason to have
two copies of this plus all the #ifdefs. --ryan. */
@ -209,7 +204,7 @@ char *SDL_GetBasePath(void)
retval = readSymLink("/proc/self/path/a.out");
#else
retval = readSymLink("/proc/self/exe"); /* linux. */
if (retval == NULL) {
if (!retval) {
/* older kernels don't have /proc/self ... try PID version... */
char path[64];
const int rc = SDL_snprintf(path, sizeof(path),
@ -225,10 +220,9 @@ char *SDL_GetBasePath(void)
#ifdef __SOLARIS__ /* try this as a fallback if /proc didn't pan out */
if (!retval) {
const char *path = getexecname();
if ((path != NULL) && (path[0] == '/')) { /* must be absolute path... */
if ((path) && (path[0] == '/')) { /* must be absolute path... */
retval = SDL_strdup(path);
if (retval == NULL) {
SDL_OutOfMemory();
if (!retval) {
return NULL;
}
}
@ -237,9 +231,9 @@ char *SDL_GetBasePath(void)
/* If we had access to argv[0] here, we could check it for a path,
or troll through $PATH looking for it, too. */
if (retval != NULL) { /* chop off filename. */
if (retval) { /* chop off filename. */
char *ptr = SDL_strrchr(retval, '/');
if (ptr != NULL) {
if (ptr) {
*(ptr + 1) = '\0';
} else { /* shouldn't happen, but just in case... */
SDL_free(retval);
@ -247,10 +241,10 @@ char *SDL_GetBasePath(void)
}
}
if (retval != NULL) {
if (retval) {
/* try to shrink buffer... */
char *ptr = (char *)SDL_realloc(retval, SDL_strlen(retval) + 1);
if (ptr != NULL) {
if (ptr) {
retval = ptr; /* oh well if it failed. */
}
}
@ -273,18 +267,18 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
if (envr == NULL) {
if (!envr) {
/* You end up with "$HOME/.local/share/Game Name 2" */
envr = SDL_getenv("HOME");
if (envr == NULL) {
if (!envr) {
/* we could take heroic measures with /etc/passwd, but oh well. */
SDL_SetError("neither XDG_DATA_HOME nor HOME environment is set");
return NULL;
@ -301,8 +295,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
len += SDL_strlen(append) + SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
if (!retval) {
return NULL;
}
@ -372,15 +365,15 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa
home_dir = SDL_getenv ("HOME");
if (home_dir == NULL)
if (!home_dir)
goto error;
config_home = SDL_getenv ("XDG_CONFIG_HOME");
if (config_home == NULL || config_home[0] == 0)
if (!config_home || config_home[0] == 0)
{
l = SDL_strlen (home_dir) + SDL_strlen ("/.config/user-dirs.dirs") + 1;
config_file = (char*) SDL_malloc (l);
if (config_file == NULL)
if (!config_file)
goto error;
SDL_strlcpy (config_file, home_dir, l);
@ -390,7 +383,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa
{
l = SDL_strlen (config_home) + SDL_strlen ("/user-dirs.dirs") + 1;
config_file = (char*) SDL_malloc (l);
if (config_file == NULL)
if (!config_file)
goto error;
SDL_strlcpy (config_file, config_home, l);
@ -399,7 +392,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa
file = fopen (config_file, "r");
SDL_free (config_file);
if (file == NULL)
if (!file)
goto error;
user_dir = NULL;
@ -452,7 +445,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa
{
l = SDL_strlen (home_dir) + 1 + SDL_strlen (p) + 1;
user_dir = (char*) SDL_malloc (l);
if (user_dir == NULL)
if (!user_dir)
goto error2;
SDL_strlcpy (user_dir, home_dir, l);
@ -461,7 +454,7 @@ static char *xdg_user_dir_lookup_with_fallback (const char *type, const char *fa
else
{
user_dir = (char*) SDL_malloc (SDL_strlen (p) + 1);
if (user_dir == NULL)
if (!user_dir)
goto error2;
*user_dir = 0;
@ -493,12 +486,12 @@ static char *xdg_user_dir_lookup (const char *type)
char *dir, *home_dir, *user_dir;
dir = xdg_user_dir_lookup_with_fallback(type, NULL);
if (dir != NULL)
if (dir)
return dir;
home_dir = SDL_getenv("HOME");
if (home_dir == NULL)
if (!home_dir)
return NULL;
/* Special case desktop for historical compatibility */
@ -506,7 +499,7 @@ static char *xdg_user_dir_lookup (const char *type)
{
user_dir = (char*) SDL_malloc(SDL_strlen(home_dir) +
SDL_strlen("/Desktop") + 1);
if (user_dir == NULL)
if (!user_dir)
return NULL;
strcpy(user_dir, home_dir);
@ -541,13 +534,7 @@ char *SDL_GetUserFolder(SDL_Folder folder)
return NULL;
}
retval = SDL_strdup(param);
if (!retval) {
SDL_OutOfMemory();
}
return retval;
return SDL_strdup(param);
case SDL_FOLDER_DESKTOP:
param = "DESKTOP";

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -48,11 +48,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
char *ptr = NULL;
size_t len = 0;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
@ -60,8 +60,7 @@ char *SDL_GetPrefPath(const char *org, const char *app)
len += SDL_strlen(org) + SDL_strlen(app) + 3;
retval = (char *)SDL_malloc(len);
if (retval == NULL) {
SDL_OutOfMemory();
if (!retval) {
return NULL;
}

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -51,9 +51,8 @@ char *SDL_GetBasePath(void)
while (SDL_TRUE) {
void *ptr = SDL_realloc(path, buflen * sizeof(WCHAR));
if (ptr == NULL) {
if (!ptr) {
SDL_free(path);
SDL_OutOfMemory();
return NULL;
}
@ -108,11 +107,11 @@ char *SDL_GetPrefPath(const char *org, const char *app)
size_t new_wpath_len = 0;
BOOL api_result = FALSE;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
@ -122,15 +121,13 @@ char *SDL_GetPrefPath(const char *org, const char *app)
}
worg = WIN_UTF8ToStringW(org);
if (worg == NULL) {
SDL_OutOfMemory();
if (!worg) {
return NULL;
}
wapp = WIN_UTF8ToStringW(app);
if (wapp == NULL) {
if (!wapp) {
SDL_free(worg);
SDL_OutOfMemory();
return NULL;
}

View File

@ -1,6 +1,6 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2023 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -106,7 +106,7 @@ SDL_WinRTGetFSPathUTF8(SDL_WinRT_Path pathType)
}
const wchar_t *ucs2Path = SDL_WinRTGetFSPathUNICODE(pathType);
if (ucs2Path == NULL) {
if (!ucs2Path) {
return NULL;
}
@ -123,15 +123,14 @@ SDL_GetBasePath(void)
size_t destPathLen;
char *destPath = NULL;
if (srcPath == NULL) {
if (!srcPath) {
SDL_SetError("Couldn't locate our basepath: %s", SDL_GetError());
return NULL;
}
destPathLen = SDL_strlen(srcPath) + 2;
destPath = (char *)SDL_malloc(destPathLen);
if (destPath == NULL) {
SDL_OutOfMemory();
if (!destPath) {
return NULL;
}
@ -156,16 +155,16 @@ SDL_GetPrefPath(const char *org, const char *app)
size_t new_wpath_len = 0;
BOOL api_result = FALSE;
if (app == NULL) {
if (!app) {
SDL_InvalidParamError("app");
return NULL;
}
if (org == NULL) {
if (!org) {
org = "";
}
srcPath = SDL_WinRTGetFSPathUNICODE(SDL_WINRT_PATH_LOCAL_FOLDER);
if (srcPath == NULL) {
if (!srcPath) {
SDL_SetError("Unable to find a source path");
return NULL;
}
@ -177,15 +176,13 @@ SDL_GetPrefPath(const char *org, const char *app)
SDL_wcslcpy(path, srcPath, SDL_arraysize(path));
worg = WIN_UTF8ToString(org);
if (worg == NULL) {
SDL_OutOfMemory();
if (!worg) {
return NULL;
}
wapp = WIN_UTF8ToString(app);
if (wapp == NULL) {
if (!wapp) {
SDL_free(worg);
SDL_OutOfMemory();
return NULL;
}