Skip to content

Commit 5827924

Browse files
committed
Rework pg_EnvShouldBlendAlphaSDL2 for SDL3
SDL_getenv now returns a const char* instead of a char*, so rather than worry about propagating that through or casting it away, lets just have pg_EnvShouldBlendAlphaSDL2 return an int, and have the callers evaluate that instead of evaluating whether a char* is NULL or not. This requires no changes to the callers.
1 parent 4d6a8e3 commit 5827924

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src_c/base.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ static int pg_is_init = 0;
8181
static int pg_sdl_was_init = 0;
8282
SDL_Window *pg_default_window = NULL;
8383
pgSurfaceObject *pg_default_screen = NULL;
84-
static char *pg_env_blend_alpha_SDL2 = NULL;
84+
static int pg_env_blend_alpha_SDL2 = 0;
8585

8686
static void
8787
pg_install_parachute(void);
@@ -170,7 +170,7 @@ static pgSurfaceObject *
170170
pg_GetDefaultWindowSurface(void);
171171
static void
172172
pg_SetDefaultWindowSurface(pgSurfaceObject *);
173-
static char *
173+
static int
174174
pg_EnvShouldBlendAlphaSDL2(void);
175175

176176
/* compare compiled to linked, raise python error on incompatibility */
@@ -347,7 +347,7 @@ pg_init(PyObject *self, PyObject *_null)
347347
pg_sdl_was_init = SDL_Init(PG_INIT_TIMER | PG_INIT_NOPARACHUTE) == 0;
348348
#endif
349349

350-
pg_env_blend_alpha_SDL2 = SDL_getenv("PYGAME_BLEND_ALPHA_SDL2");
350+
pg_env_blend_alpha_SDL2 = SDL_getenv("PYGAME_BLEND_ALPHA_SDL2") != NULL;
351351

352352
/* initialize all pygame modules */
353353
for (i = 0; modnames[i]; i++) {
@@ -2096,7 +2096,7 @@ pg_SetDefaultConvertFormat(Uint32 format)
20962096
return pg_default_convert_format; // returns for NULL error checking
20972097
}
20982098

2099-
static char *
2099+
static int
21002100
pg_EnvShouldBlendAlphaSDL2(void)
21012101
{
21022102
return pg_env_blend_alpha_SDL2;

src_c/include/_pygame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ typedef struct pg_bufferinfo_s {
181181
(*(void (*)(pgSurfaceObject *))PYGAMEAPI_GET_SLOT(base, 22))
182182

183183
#define pg_EnvShouldBlendAlphaSDL2 \
184-
(*(char *(*)(void))PYGAMEAPI_GET_SLOT(base, 23))
184+
(*(int (*)(void))PYGAMEAPI_GET_SLOT(base, 23))
185185

186186
#define pg_GetDefaultConvertFormat \
187187
(*(SDL_PixelFormat * (*)(void)) PYGAMEAPI_GET_SLOT(base, 27))

0 commit comments

Comments
 (0)