Skip to content

Commit

Permalink
dynapi: use DosScanEnv() for os/2.
Browse files Browse the repository at this point in the history
(cherry picked from commit ee49025)
  • Loading branch information
sezero committed Feb 20, 2025
1 parent b766193 commit c49e57b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/dynapi/SDL_dynapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,19 +307,24 @@ extern SDL_NORETURN void SDL_ExitProcess(int exitcode);
static void
SDL_InitDynamicAPILocked(void)
{
SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
SDL_bool use_internal = SDL_TRUE;

/* this can't use SDL_getenv_REAL, because it might allocate memory before the app can set their allocator */
#if defined(WIN32) || defined(_WIN32) || defined(__CYGWIN__)
/* We've always used LoadLibraryA for this, so this has never worked with Unicode paths on Windows. Sorry. */
char envbuf[512]; /* overflows will just report as environment variable being unset, but LoadLibraryA has a MAX_PATH of 260 anyhow, apparently. */
const DWORD rc = GetEnvironmentVariableA("SDL_DYNAMIC_API", envbuf, (DWORD) sizeof (envbuf));
char *libname = ((rc != 0) && (rc < sizeof (envbuf))) ? envbuf : NULL;
#elif defined(__OS2__)
char * libname;
if (DosScanEnv("SDL_DYNAMIC_API", &libname) != NO_ERROR) {
libname = NULL;
}
#else
const char *libname = getenv("SDL_DYNAMIC_API");
#endif

SDL_DYNAPI_ENTRYFN entry = NULL; /* funcs from here by default. */
SDL_bool use_internal = SDL_TRUE;

if (libname) {
entry = (SDL_DYNAPI_ENTRYFN) get_sdlapi_entry(libname, "SDL_DYNAPI_entry");
if (!entry) {
Expand Down

0 comments on commit c49e57b

Please sign in to comment.