Project

General

Profile

Feature #2474 ยป 0078-SDL3_rotozoom.c-Replace-NULL-with-nullptr.patch

Marko Lindqvist, 11/10/2026 04:41 AM

View differences:

client/gui-sdl3/SDL3_gfx/SDL3_rotozoom.c
/*
* Allocate memory for row/column increments
*/
if ((sax = (int *) malloc((dst->w + 1) * sizeof(Uint32))) == NULL) {
if ((sax = (int *) malloc((dst->w + 1) * sizeof(Uint32))) == nullptr) {
return (-1);
}
if ((say = (int *) malloc((dst->h + 1) * sizeof(Uint32))) == NULL) {
if ((say = (int *) malloc((dst->h + 1) * sizeof(Uint32))) == nullptr) {
free(sax);
return (-1);
}
......
\param src Source surface to rotate.
\param numClockwiseTurns Number of clockwise 90 degree turns to apply to the source.
\returns The new, rotated surface; or NULL for surfaces with incorrect input format.
\returns The new, rotated surface; or nullptr for surfaces with incorrect input format.
*/
SDL_Surface* rotateSurface90Degrees(SDL_Surface* src, int numClockwiseTurns)
{
......
/* Has to be a valid surface pointer and be a Nbit surface where n is divisible by 8 */
if (!src) {
SDL_SetError("NULL source surface or source surface format");
return NULL;
SDL_SetError("nullptr source surface or source surface format");
return nullptr;
}
details = SDL_GetPixelFormatDetails(src->format);
if ((details->bits_per_pixel % 8) != 0) {
SDL_SetError("Invalid source surface bit depth");
return NULL;
return nullptr;
}
/* normalize numClockwiseTurns */
......
dst = SDL_CreateSurface( newWidth, newHeight, SDL_PIXELFORMAT_RGBA8888);
if(!dst) {
SDL_SetError("Could not create destination surface");
return NULL;
return nullptr;
}
if (SDL_MUSTLOCK(src)) {
......
/*
* Sanity check
*/
if (src == NULL) {
return (NULL);
if (src == nullptr) {
return (nullptr);
}
details = SDL_GetPixelFormatDetails(src->format);
......
rz_src =
SDL_CreateSurface(src->w, src->h, SDL_PIXELFORMAT_RGBA8888);
SDL_BlitSurface(src, NULL, rz_src, NULL);
SDL_BlitSurface(src, nullptr, rz_src, nullptr);
src_converted = 1;
}
......
/*
* Alloc space to completely contain the rotated surface
*/
rz_dst = NULL;
rz_dst = nullptr;
/*
* Target surface is 32bit with source RGBA/ABGR ordering
......
rz_src->format);
/* Check target */
if (rz_dst == NULL)
return NULL;
if (rz_dst == nullptr)
return nullptr;
/* Adjust for guard rows */
rz_dst->h = dstheight;
......
/*
* Alloc space to completely contain the zoomed surface
*/
rz_dst = NULL;
rz_dst = nullptr;
/*
* Target surface is 32bit with source RGBA/ABGR ordering
......
rz_src->format);
/* Check target */
if (rz_dst == NULL)
return NULL;
if (rz_dst == nullptr)
return nullptr;
/* Adjust for guard rows */
rz_dst->h = dstheight;
......
/*
* Sanity check
*/
if (src == NULL)
return (NULL);
if (src == nullptr)
return (nullptr);
details = SDL_GetPixelFormatDetails(src->format);
......
rz_src =
SDL_CreateSurface(src->w, src->h,
SDL_PIXELFORMAT_RGBA8888);
if (rz_src == NULL) {
return NULL;
if (rz_src == nullptr) {
return nullptr;
}
SDL_BlitSurface(src, NULL, rz_src, NULL);
SDL_BlitSurface(src, nullptr, rz_src, nullptr);
src_converted = 1;
}
......
/*
* Alloc space to completely contain the zoomed surface
*/
rz_dst = NULL;
rz_dst = nullptr;
/*
* Target surface is 32bit with source RGBA/ABGR ordering
......
rz_src->format);
/* Check target */
if (rz_dst == NULL) {
if (rz_dst == nullptr) {
/*
* Cleanup temp surface
*/
if (src_converted) {
SDL_DestroySurface(rz_src);
}
return NULL;
return nullptr;
}
/* Adjust for guard rows */
......
{
int result;
SDL_Surface *rz_src;
SDL_Surface *rz_dst = NULL;
SDL_Surface *rz_dst = nullptr;
int dstwidth, dstheight;
int src_converted;
int haveError = 0;
......
/*
* Sanity check
*/
if (src == NULL) {
return (NULL);
if (src == nullptr) {
return (nullptr);
}
details = SDL_GetPixelFormatDetails(src->format);
......
*/
rz_src = SDL_CreateSurface(src->w, src->h,
SDL_PIXELFORMAT_RGBA8888);
if (rz_src==NULL) {
if (rz_src==nullptr) {
haveError = 1;
goto exitShrinkSurface;
}
SDL_BlitSurface(src, NULL, rz_src, NULL);
SDL_BlitSurface(src, nullptr, rz_src, nullptr);
src_converted = 1;
}
......
rz_src->format);
/* Check target */
if (rz_dst == NULL) {
if (rz_dst == nullptr) {
haveError = 1;
goto exitShrinkSurface;
}
......
* Call the 32bit transformation routine to do the shrinking (using alpha)
*/
result = _shrinkSurfaceRGBA(rz_src, rz_dst, factorx, factory);
if ((result!=0) || (rz_dst==NULL)) {
if ((result!=0) || (rz_dst==nullptr)) {
haveError = 1;
goto exitShrinkSurface;
}
exitShrinkSurface:
if (rz_src!=NULL) {
if (rz_src!=nullptr) {
/*
* Unlock source surface
*/
......
/* Check error state; maybe need to cleanup destination */
if (haveError==1) {
if (rz_dst!=NULL) {
if (rz_dst!=nullptr) {
SDL_DestroySurface(rz_dst);
}
rz_dst=NULL;
rz_dst=nullptr;
}
/*
    (1-1/1)