Skip to content
Snippets Groups Projects
Commit 647fd0cc authored by Deucе's avatar Deucе :ok_hand_tone4:
Browse files

Don't leak sdl_dll (make it global)

Also, don't do stupid things if called more than once.
parent 88e8688b
No related branches found
No related tags found
No related merge requests found
Pipeline #7796 passed
......@@ -15,14 +15,20 @@ struct sdlfuncs xpbeep_sdl;
#include "xp_dl.h"
static int sdl_funcs_loaded = 0;
static bool sdl_funcs_failed = false;
static int sdl_initialized = 0;
static int sdl_audio_initialized = 0;
static dll_handle sdl_dll;
int xpbeep_load_sdl_funcs(struct sdlfuncs *sdlf)
{
dll_handle sdl_dll;
const char *libnames[] = {"SDL", "SDL-1.2", "SDL-1.1", NULL};
if (sdl_funcs_failed)
return -1;
sdl_funcs_failed = true;
if (sdl_funcs_loaded)
return 0;
putenv("SDL_VIDEO_ALLOW_SCREENSAVER=1");
sdlf->gotfuncs = 0;
if ((sdl_dll = xp_dlopen(libnames, RTLD_LAZY | RTLD_GLOBAL, SDL_PATCHLEVEL)) == NULL)
......@@ -86,6 +92,7 @@ int xpbeep_load_sdl_funcs(struct sdlfuncs *sdlf)
}
sdlf->gotfuncs = 1;
sdl_funcs_loaded = 1;
sdl_funcs_failed = false;
return 0;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment