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

@@ -142,7 +142,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, Uint32 format)
/* Allocate the surface */
surface = (SDL_Surface *)SDL_calloc(1, sizeof(*surface));
if (surface == NULL) {
if (!surface) {
SDL_OutOfMemory();
return NULL;
}
@@ -160,7 +160,7 @@ SDL_Surface *SDL_CreateSurface(int width, int height, Uint32 format)
if (SDL_ISPIXELFORMAT_INDEXED(surface->format->format)) {
SDL_Palette *palette =
SDL_CreatePalette((1 << surface->format->BitsPerPixel));
if (palette == NULL) {
if (!palette) {
SDL_DestroySurface(surface);
return NULL;
}
@@ -225,7 +225,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitc
return NULL;
}
if (pitch == 0 && pixels == NULL) {
if (pitch == 0 && !pixels) {
/* The application will fill these in later with valid values */
} else {
size_t minimalPitch;
@@ -243,7 +243,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitc
}
surface = SDL_CreateSurface(0, 0, format);
if (surface != NULL) {
if (surface) {
surface->flags |= SDL_PREALLOC;
surface->pixels = pixels;
surface->w = width;
@@ -256,7 +256,7 @@ SDL_Surface *SDL_CreateSurfaceFrom(void *pixels, int width, int height, int pitc
SDL_PropertiesID SDL_GetSurfaceProperties(SDL_Surface *surface)
{
if (surface == NULL) {
if (!surface) {
SDL_InvalidParamError("surface");
return 0;
}
@@ -269,7 +269,7 @@ SDL_PropertiesID SDL_GetSurfaceProperties(SDL_Surface *surface)
int SDL_SetSurfacePalette(SDL_Surface *surface, SDL_Palette *palette)
{
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
if (SDL_SetPixelFormatPalette(surface->format, palette) < 0) {
@@ -284,7 +284,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
{
int flags;
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@@ -302,7 +302,7 @@ int SDL_SetSurfaceRLE(SDL_Surface *surface, int flag)
SDL_bool SDL_SurfaceHasRLE(SDL_Surface *surface)
{
if (surface == NULL) {
if (!surface) {
return SDL_FALSE;
}
@@ -317,7 +317,7 @@ int SDL_SetSurfaceColorKey(SDL_Surface *surface, int flag, Uint32 key)
{
int flags;
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@@ -345,7 +345,7 @@ int SDL_SetSurfaceColorKey(SDL_Surface *surface, int flag, Uint32 key)
SDL_bool SDL_SurfaceHasColorKey(SDL_Surface *surface)
{
if (surface == NULL) {
if (!surface) {
return SDL_FALSE;
}
@@ -358,7 +358,7 @@ SDL_bool SDL_SurfaceHasColorKey(SDL_Surface *surface)
int SDL_GetSurfaceColorKey(SDL_Surface *surface, Uint32 *key)
{
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@@ -378,7 +378,7 @@ static void SDL_ConvertColorkeyToAlpha(SDL_Surface *surface, SDL_bool ignore_alp
{
int x, y, bpp;
if (surface == NULL) {
if (!surface) {
return;
}
@@ -467,7 +467,7 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
{
int flags;
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@@ -489,7 +489,7 @@ int SDL_SetSurfaceColorMod(SDL_Surface *surface, Uint8 r, Uint8 g, Uint8 b)
int SDL_GetSurfaceColorMod(SDL_Surface *surface, Uint8 *r, Uint8 *g, Uint8 *b)
{
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@@ -509,7 +509,7 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
{
int flags;
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@@ -529,7 +529,7 @@ int SDL_SetSurfaceAlphaMod(SDL_Surface *surface, Uint8 alpha)
int SDL_GetSurfaceAlphaMod(SDL_Surface *surface, Uint8 *alpha)
{
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@@ -543,7 +543,7 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
{
int flags, status;
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
@@ -580,11 +580,11 @@ int SDL_SetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode blendMode)
int SDL_GetSurfaceBlendMode(SDL_Surface *surface, SDL_BlendMode *blendMode)
{
if (surface == NULL) {
if (!surface) {
return SDL_InvalidParamError("surface");
}
if (blendMode == NULL) {
if (!blendMode) {
return 0;
}
@@ -613,7 +613,7 @@ SDL_bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect)
SDL_Rect full_rect;
/* Don't do anything if there's no surface to act on */
if (surface == NULL) {
if (!surface) {
return SDL_FALSE;
}
@@ -624,7 +624,7 @@ SDL_bool SDL_SetSurfaceClipRect(SDL_Surface *surface, const SDL_Rect *rect)
full_rect.h = surface->h;
/* Set the clipping rectangle */
if (rect == NULL) {
if (!rect) {
surface->clip_rect = full_rect;
return SDL_TRUE;
}
@@ -682,7 +682,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect,
int srcx, srcy, w, h;
/* Make sure the surfaces aren't locked */
if (src == NULL || dst == NULL) {
if (!src || !dst) {
return SDL_InvalidParamError("SDL_BlitSurface(): src/dst");
}
if (src->locked || dst->locked) {
@@ -690,7 +690,7 @@ int SDL_BlitSurface(SDL_Surface *src, const SDL_Rect *srcrect,
}
/* If the destination rectangle is NULL, use the entire dest surface */
if (dstrect == NULL) {
if (!dstrect) {
fulldst.x = fulldst.y = 0;
fulldst.w = dst->w;
fulldst.h = dst->h;
@@ -794,14 +794,14 @@ int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
int dst_w, dst_h;
/* Make sure the surfaces aren't locked */
if (src == NULL || dst == NULL) {
if (!src || !dst) {
return SDL_InvalidParamError("SDL_BlitSurfaceScaled(): src/dst");
}
if (src->locked || dst->locked) {
return SDL_SetError("Surfaces must not be locked during blit");
}
if (srcrect == NULL) {
if (!srcrect) {
src_w = src->w;
src_h = src->h;
} else {
@@ -809,7 +809,7 @@ int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
src_h = srcrect->h;
}
if (dstrect == NULL) {
if (!dstrect) {
dst_w = dst->w;
dst_h = dst->h;
} else {
@@ -825,7 +825,7 @@ int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
scaling_w = (double)dst_w / src_w;
scaling_h = (double)dst_h / src_h;
if (dstrect == NULL) {
if (!dstrect) {
dst_x0 = 0;
dst_y0 = 0;
dst_x1 = dst_w;
@@ -837,7 +837,7 @@ int SDL_PrivateBlitSurfaceScaled(SDL_Surface *src, const SDL_Rect *srcrect,
dst_y1 = dst_y0 + dst_h;
}
if (srcrect == NULL) {
if (!srcrect) {
src_x0 = 0;
src_y0 = 0;
src_x1 = src_w;
@@ -1120,17 +1120,17 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *for
Uint8 *palette_saved_alpha = NULL;
int palette_saved_alpha_ncolors = 0;
if (surface == NULL) {
if (!surface) {
SDL_InvalidParamError("surface");
return NULL;
}
if (format == NULL) {
if (!format) {
SDL_InvalidParamError("format");
return NULL;
}
/* Check for empty destination palette! (results in empty image) */
if (format->palette != NULL) {
if (format->palette) {
int i;
for (i = 0; i < format->palette->ncolors; ++i) {
if ((format->palette->colors[i].r != 0xFF) || (format->palette->colors[i].g != 0xFF) || (format->palette->colors[i].b != 0xFF)) {
@@ -1145,7 +1145,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *for
/* Create a new surface with the desired format */
convert = SDL_CreateSurface(surface->w, surface->h, format->format);
if (convert == NULL) {
if (!convert) {
return NULL;
}
@@ -1303,7 +1303,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *for
/* Create a dummy surface to get the colorkey converted */
tmp = SDL_CreateSurface(1, 1, surface->format->format);
if (tmp == NULL) {
if (!tmp) {
SDL_DestroySurface(convert);
return NULL;
}
@@ -1319,7 +1319,7 @@ SDL_Surface *SDL_ConvertSurface(SDL_Surface *surface, const SDL_PixelFormat *for
/* Conversion of the colorkey */
tmp2 = SDL_ConvertSurface(tmp, format);
if (tmp2 == NULL) {
if (!tmp2) {
SDL_DestroySurface(tmp);
SDL_DestroySurface(convert);
return NULL;
@@ -1425,13 +1425,13 @@ int SDL_ConvertPixels(int width, int height,
void *nonconst_src = (void *)src;
int ret;
if (src == NULL) {
if (!src) {
return SDL_InvalidParamError("src");
}
if (!src_pitch) {
return SDL_InvalidParamError("src_pitch");
}
if (dst == NULL) {
if (!dst) {
return SDL_InvalidParamError("dst");
}
if (!dst_pitch) {
@@ -1507,13 +1507,13 @@ int SDL_PremultiplyAlpha(int width, int height,
Uint32 dstpixel;
Uint32 dstR, dstG, dstB, dstA;
if (src == NULL) {
if (!src) {
return SDL_InvalidParamError("src");
}
if (!src_pitch) {
return SDL_InvalidParamError("src_pitch");
}
if (dst == NULL) {
if (!dst) {
return SDL_InvalidParamError("dst");
}
if (!dst_pitch) {
@@ -1555,7 +1555,7 @@ int SDL_PremultiplyAlpha(int width, int height,
*/
void SDL_DestroySurface(SDL_Surface *surface)
{
if (surface == NULL) {
if (!surface) {
return;
}
if (surface->flags & SDL_DONTFREE) {