Pointer as bool (libsdl-org#7214)

This commit is contained in:
Sylvain
2023-11-09 22:29:15 +01:00
committed by Sam Lantinga
parent 23db971681
commit d8600f717e
371 changed files with 2448 additions and 2442 deletions

View File

@@ -34,21 +34,21 @@ 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) {
if (!buffer) {
SDL_OutOfMemory();
return NULL;
}
}
if (!__unixify_std(ro_path, buffer, buf_len, filetype)) {
if (in_buf == NULL) {
if (!in_buf) {
SDL_free(buffer);
}
@@ -88,7 +88,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) {
if (!buf) {
SDL_OutOfMemory();
return NULL;
}
@@ -117,7 +117,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 +137,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,22 +158,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) {
if (!dir) {
SDL_OutOfMemory();
SDL_free(canon);
return NULL;
@@ -188,7 +188,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;