mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-03-09 10:35:37 +00:00
[SDL2] pointer boolean (#8523)
This commit is contained in:
@@ -47,7 +47,7 @@ static size_t SDL_envmemlen = 0;
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) {
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
{
|
||||
/* Input validation */
|
||||
if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) {
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
char *new_variable;
|
||||
|
||||
/* Input validation */
|
||||
if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) {
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
/* This leaks. Sorry. Get a better OS so we don't have to do this. */
|
||||
len = SDL_strlen(name) + SDL_strlen(value) + 2;
|
||||
new_variable = (char *)SDL_malloc(len);
|
||||
if (new_variable == NULL) {
|
||||
if (!new_variable) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
char *new_variable;
|
||||
|
||||
/* Input validation */
|
||||
if (name == NULL || *name == '\0' || SDL_strchr(name, '=') != NULL || value == NULL) {
|
||||
if (!name || *name == '\0' || SDL_strchr(name, '=') != NULL || !value) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ int SDL_setenv(const char *name, const char *value, int overwrite)
|
||||
/* Allocate memory for the variable */
|
||||
len = SDL_strlen(name) + SDL_strlen(value) + 2;
|
||||
new_variable = (char *)SDL_malloc(len);
|
||||
if (new_variable == NULL) {
|
||||
if (!new_variable) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ char *SDL_getenv(const char *name)
|
||||
#endif
|
||||
|
||||
/* Input validation */
|
||||
if (name == NULL || *name == '\0') {
|
||||
if (!name || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -188,7 +188,7 @@ char *SDL_getenv(const char *name)
|
||||
size_t bufferlen;
|
||||
|
||||
/* Input validation */
|
||||
if (name == NULL || *name == '\0') {
|
||||
if (!name || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -199,7 +199,7 @@ char *SDL_getenv(const char *name)
|
||||
}
|
||||
if (bufferlen > SDL_envmemlen) {
|
||||
char *newmem = (char *)SDL_realloc(SDL_envmem, bufferlen);
|
||||
if (newmem == NULL) {
|
||||
if (!newmem) {
|
||||
return NULL;
|
||||
}
|
||||
SDL_envmem = newmem;
|
||||
@@ -215,14 +215,14 @@ char *SDL_getenv(const char *name)
|
||||
char *value;
|
||||
|
||||
/* Input validation */
|
||||
if (name == NULL || *name == '\0') {
|
||||
if (!name || *name == '\0') {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
value = (char *)0;
|
||||
if (SDL_env) {
|
||||
len = SDL_strlen(name);
|
||||
for (i = 0; SDL_env[i] && value == NULL; ++i) {
|
||||
for (i = 0; SDL_env[i] && !value; ++i) {
|
||||
if ((SDL_strncmp(SDL_env[i], name, len) == 0) &&
|
||||
(SDL_env[i][len] == '=')) {
|
||||
value = &SDL_env[i][len + 1];
|
||||
|
||||
@@ -166,28 +166,28 @@ static const char *getlocale(char *buffer, size_t bufsize)
|
||||
char *ptr;
|
||||
|
||||
lang = SDL_getenv("LC_ALL");
|
||||
if (lang == NULL) {
|
||||
if (!lang) {
|
||||
lang = SDL_getenv("LC_CTYPE");
|
||||
}
|
||||
if (lang == NULL) {
|
||||
if (!lang) {
|
||||
lang = SDL_getenv("LC_MESSAGES");
|
||||
}
|
||||
if (lang == NULL) {
|
||||
if (!lang) {
|
||||
lang = SDL_getenv("LANG");
|
||||
}
|
||||
if (lang == NULL || !*lang || SDL_strcmp(lang, "C") == 0) {
|
||||
if (!lang || !*lang || SDL_strcmp(lang, "C") == 0) {
|
||||
lang = "ASCII";
|
||||
}
|
||||
|
||||
/* We need to trim down strings like "en_US.UTF-8@blah" to "UTF-8" */
|
||||
ptr = SDL_strchr(lang, '.');
|
||||
if (ptr != NULL) {
|
||||
if (ptr) {
|
||||
lang = ptr + 1;
|
||||
}
|
||||
|
||||
SDL_strlcpy(buffer, lang, bufsize);
|
||||
ptr = SDL_strchr(buffer, '@');
|
||||
if (ptr != NULL) {
|
||||
if (ptr) {
|
||||
*ptr = '\0'; /* chop end of string. */
|
||||
}
|
||||
|
||||
@@ -202,10 +202,10 @@ SDL_iconv_t SDL_iconv_open(const char *tocode, const char *fromcode)
|
||||
char fromcode_buffer[64];
|
||||
char tocode_buffer[64];
|
||||
|
||||
if (fromcode == NULL || !*fromcode) {
|
||||
if (!fromcode || !*fromcode) {
|
||||
fromcode = getlocale(fromcode_buffer, sizeof(fromcode_buffer));
|
||||
}
|
||||
if (tocode == NULL || !*tocode) {
|
||||
if (!tocode || !*tocode) {
|
||||
tocode = getlocale(tocode_buffer, sizeof(tocode_buffer));
|
||||
}
|
||||
for (i = 0; i < SDL_arraysize(encodings); ++i) {
|
||||
@@ -245,11 +245,11 @@ SDL_iconv(SDL_iconv_t cd,
|
||||
Uint32 ch = 0;
|
||||
size_t total;
|
||||
|
||||
if (inbuf == NULL || !*inbuf) {
|
||||
if (!inbuf || !*inbuf) {
|
||||
/* Reset the context */
|
||||
return 0;
|
||||
}
|
||||
if (outbuf == NULL || !*outbuf || outbytesleft == NULL || !*outbytesleft) {
|
||||
if (!outbuf || !*outbuf || !outbytesleft || !*outbytesleft) {
|
||||
return SDL_ICONV_E2BIG;
|
||||
}
|
||||
src = *inbuf;
|
||||
@@ -795,10 +795,10 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb
|
||||
size_t outbytesleft;
|
||||
size_t retCode = 0;
|
||||
|
||||
if (tocode == NULL || !*tocode) {
|
||||
if (!tocode || !*tocode) {
|
||||
tocode = "UTF-8";
|
||||
}
|
||||
if (fromcode == NULL || !*fromcode) {
|
||||
if (!fromcode || !*fromcode) {
|
||||
fromcode = "UTF-8";
|
||||
}
|
||||
cd = SDL_iconv_open(tocode, fromcode);
|
||||
@@ -808,7 +808,7 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb
|
||||
|
||||
stringsize = inbytesleft;
|
||||
string = (char *)SDL_malloc(stringsize + sizeof(Uint32));
|
||||
if (string == NULL) {
|
||||
if (!string) {
|
||||
SDL_iconv_close(cd);
|
||||
return NULL;
|
||||
}
|
||||
@@ -825,7 +825,7 @@ char *SDL_iconv_string(const char *tocode, const char *fromcode, const char *inb
|
||||
char *oldstring = string;
|
||||
stringsize *= 2;
|
||||
string = (char *)SDL_realloc(string, stringsize + sizeof(Uint32));
|
||||
if (string == NULL) {
|
||||
if (!string) {
|
||||
SDL_free(oldstring);
|
||||
SDL_iconv_close(cd);
|
||||
return NULL;
|
||||
|
||||
@@ -1152,7 +1152,7 @@ int SDL_vsscanf(const char *text, const char *fmt, va_list ap)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
if (text == NULL || !*text) {
|
||||
if (!text || !*text) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1544,7 +1544,7 @@ static size_t SDL_PrintString(char *text, size_t maxlen, SDL_FormatInfo *info, c
|
||||
size_t length = 0;
|
||||
size_t slen, sz;
|
||||
|
||||
if (string == NULL) {
|
||||
if (!string) {
|
||||
string = "(null)";
|
||||
}
|
||||
|
||||
@@ -1604,7 +1604,7 @@ static void SDL_IntPrecisionAdjust(char *num, size_t maxlen, SDL_FormatInfo *inf
|
||||
{ /* left-pad num with zeroes. */
|
||||
size_t sz, pad, have_sign;
|
||||
|
||||
if (info == NULL) {
|
||||
if (!info) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1992,7 +1992,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap)
|
||||
*strp = NULL;
|
||||
|
||||
p = (char *)SDL_malloc(size);
|
||||
if (p == NULL) {
|
||||
if (!p) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -2018,7 +2018,7 @@ int SDL_vasprintf(char **strp, const char *fmt, va_list ap)
|
||||
size = retval + 1; /* Precisely what is needed */
|
||||
|
||||
np = (char *)SDL_realloc(p, size);
|
||||
if (np == NULL) {
|
||||
if (!np) {
|
||||
SDL_free(p);
|
||||
return -1;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user