mirror of https://github.com/libsdl-org/SDL
SDL_CreateEnvironment() fills the environment with a non-zero parameter
This commit is contained in:
parent
76c469910e
commit
aa7357a14d
|
@ -1030,11 +1030,11 @@ extern SDL_DECLSPEC void SDLCALL SDL_CleanupEnvironment(void);
|
||||||
/**
|
/**
|
||||||
* Create a set of environment variables
|
* Create a set of environment variables
|
||||||
*
|
*
|
||||||
* \param empty SDL_TRUE to create an empty environment, SDL_FALSE to initialize it from the C runtime environment.
|
* \param populated SDL_TRUE to initialize it from the C runtime environment, SDL_FALSE to create an empty environment.
|
||||||
* \returns a pointer to the new environment or NULL on failure; call SDL_GetError()
|
* \returns a pointer to the new environment or NULL on failure; call SDL_GetError()
|
||||||
* for more information.
|
* for more information.
|
||||||
*
|
*
|
||||||
* \threadsafety If `empty` is SDL_TRUE, it is safe to call this function from any thread, otherwise it is safe if no other threads are calling setenv() or unsetenv()
|
* \threadsafety If `populated` is SDL_FALSE, it is safe to call this function from any thread, otherwise it is safe if no other threads are calling setenv() or unsetenv()
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
|
@ -1044,7 +1044,7 @@ extern SDL_DECLSPEC void SDLCALL SDL_CleanupEnvironment(void);
|
||||||
* \sa SDL_UnsetEnvironmentVariable
|
* \sa SDL_UnsetEnvironmentVariable
|
||||||
* \sa SDL_DestroyEnvironment
|
* \sa SDL_DestroyEnvironment
|
||||||
*/
|
*/
|
||||||
extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_CreateEnvironment(SDL_bool empty);
|
extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_CreateEnvironment(SDL_bool populated);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the value of a variable in the environment.
|
* Get the value of a variable in the environment.
|
||||||
|
|
|
@ -207,7 +207,7 @@ static void run_zenity(zenityArgs* arg_struct)
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
env = SDL_CreateEnvironment(SDL_FALSE);
|
env = SDL_CreateEnvironment(true);
|
||||||
if (!env) {
|
if (!env) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ bool SDL_SYS_OpenURL(const char *url)
|
||||||
SDL_Process *process = NULL;
|
SDL_Process *process = NULL;
|
||||||
bool result = false;
|
bool result = false;
|
||||||
|
|
||||||
env = SDL_CreateEnvironment(SDL_FALSE);
|
env = SDL_CreateEnvironment(true);
|
||||||
if (!env) {
|
if (!env) {
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,7 +329,7 @@ static SDL_Environment *SDL_environment;
|
||||||
SDL_Environment *SDL_GetEnvironment(void)
|
SDL_Environment *SDL_GetEnvironment(void)
|
||||||
{
|
{
|
||||||
if (!SDL_environment) {
|
if (!SDL_environment) {
|
||||||
SDL_environment = SDL_CreateEnvironment(false);
|
SDL_environment = SDL_CreateEnvironment(true);
|
||||||
}
|
}
|
||||||
return SDL_environment;
|
return SDL_environment;
|
||||||
}
|
}
|
||||||
|
@ -344,7 +344,7 @@ void SDL_CleanupEnvironment(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_Environment *SDL_CreateEnvironment(SDL_bool empty)
|
SDL_Environment *SDL_CreateEnvironment(SDL_bool populated)
|
||||||
{
|
{
|
||||||
SDL_Environment *env = SDL_calloc(1, sizeof(*env));
|
SDL_Environment *env = SDL_calloc(1, sizeof(*env));
|
||||||
if (!env) {
|
if (!env) {
|
||||||
|
@ -360,7 +360,7 @@ SDL_Environment *SDL_CreateEnvironment(SDL_bool empty)
|
||||||
// Don't fail if we can't create a mutex (e.g. on a single-thread environment)
|
// Don't fail if we can't create a mutex (e.g. on a single-thread environment)
|
||||||
env->lock = SDL_CreateMutex();
|
env->lock = SDL_CreateMutex();
|
||||||
|
|
||||||
if (!empty) {
|
if (populated) {
|
||||||
#ifdef SDL_PLATFORM_WINDOWS
|
#ifdef SDL_PLATFORM_WINDOWS
|
||||||
LPWCH strings = GetEnvironmentStringsW();
|
LPWCH strings = GetEnvironmentStringsW();
|
||||||
if (strings) {
|
if (strings) {
|
||||||
|
|
|
@ -40,7 +40,7 @@ static char **DuplicateEnvironment(const char *key0, ...)
|
||||||
va_list ap;
|
va_list ap;
|
||||||
const char *keyN;
|
const char *keyN;
|
||||||
SDL_Environment *env = SDL_GetEnvironment();
|
SDL_Environment *env = SDL_GetEnvironment();
|
||||||
SDL_Environment *new_env = SDL_CreateEnvironment(SDL_TRUE);
|
SDL_Environment *new_env = SDL_CreateEnvironment(SDL_FALSE);
|
||||||
char **result;
|
char **result;
|
||||||
|
|
||||||
if (key0) {
|
if (key0) {
|
||||||
|
|
Loading…
Reference in New Issue