Removed SDL_CleanupEnvironment()

This commit is contained in:
Sam Lantinga 2024-09-15 09:55:38 -07:00
parent a7f1deae8d
commit 97d40b9218
7 changed files with 36 additions and 24 deletions

View File

@ -984,7 +984,6 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumAllocations(void);
* \since This struct is available since SDL 3.0.0.
*
* \sa SDL_GetEnvironment
* \sa SDL_CleanupEnvironment
* \sa SDL_CreateEnvironment
* \sa SDL_GetEnvironmentVariable
* \sa SDL_GetEnvironmentVariables
@ -999,7 +998,9 @@ typedef struct SDL_Environment SDL_Environment;
*
* This is initialized at application start and is not affected by setenv()
* and unsetenv() calls after that point. Use SDL_SetEnvironmentVariable() and
* SDL_UnsetEnvironmentVariable() if you want to modify this environment.
* SDL_UnsetEnvironmentVariable() if you want to modify this environment, or
* SDL_setenv_unsafe() or SDL_unsetenv_unsafe() if you want changes to persist
* in the C runtime environment after SDL_Quit().
*
* \returns a pointer to the environment for the process or NULL on failure;
* call SDL_GetError() for more information.
@ -1008,7 +1009,6 @@ typedef struct SDL_Environment SDL_Environment;
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_CleanupEnvironment
* \sa SDL_GetEnvironmentVariable
* \sa SDL_GetEnvironmentVariables
* \sa SDL_SetEnvironmentVariable
@ -1016,21 +1016,6 @@ typedef struct SDL_Environment SDL_Environment;
*/
extern SDL_DECLSPEC SDL_Environment * SDLCALL SDL_GetEnvironment(void);
/**
* Cleanup the process environment.
*
* This is called during SDL_Quit() to free the process environment. If
* SDL_GetEnvironment() is called afterwards, it will automatically create a
* new environment copied from the C runtime environment.
*
* \threadsafety This function is not thread-safe.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_GetEnvironment
*/
extern SDL_DECLSPEC void SDLCALL SDL_CleanupEnvironment(void);
/**
* Create a set of environment variables
*

View File

@ -49,6 +49,7 @@
#include "joystick/SDL_joystick_c.h"
#include "render/SDL_sysrender.h"
#include "sensor/SDL_sensor_c.h"
#include "stdlib/SDL_getenv_c.h"
#include "thread/SDL_thread_c.h"
#include "video/SDL_pixels_c.h"
#include "video/SDL_video_c.h"
@ -250,23 +251,23 @@ void SDL_SetMainReady(void)
void SDL_InitMainThread(void)
{
SDL_InitTLSData();
SDL_InitEnvironment();
SDL_InitTicks();
SDL_InitFilesystem();
SDL_InitLog();
SDL_InitProperties();
SDL_GetGlobalProperties();
SDL_GetEnvironment();
SDL_InitHints();
}
static void SDL_QuitMainThread(void)
{
SDL_QuitHints();
SDL_CleanupEnvironment();
SDL_QuitProperties();
SDL_QuitLog();
SDL_QuitFilesystem();
SDL_QuitTicks();
SDL_QuitEnvironment();
SDL_QuitTLSData();
}

View File

@ -52,7 +52,6 @@ SDL3_0.0.0 {
SDL_BroadcastCondition;
SDL_CaptureMouse;
SDL_ClaimWindowForGPUDevice;
SDL_CleanupEnvironment;
SDL_CleanupTLS;
SDL_ClearAudioStream;
SDL_ClearClipboardData;

View File

@ -77,7 +77,6 @@
#define SDL_BroadcastCondition SDL_BroadcastCondition_REAL
#define SDL_CaptureMouse SDL_CaptureMouse_REAL
#define SDL_ClaimWindowForGPUDevice SDL_ClaimWindowForGPUDevice_REAL
#define SDL_CleanupEnvironment SDL_CleanupEnvironment_REAL
#define SDL_CleanupTLS SDL_CleanupTLS_REAL
#define SDL_ClearAudioStream SDL_ClearAudioStream_REAL
#define SDL_ClearClipboardData SDL_ClearClipboardData_REAL

View File

@ -97,7 +97,6 @@ SDL_DYNAPI_PROC(SDL_bool,SDL_BlitSurfaceUncheckedScaled,(SDL_Surface *a, const S
SDL_DYNAPI_PROC(void,SDL_BroadcastCondition,(SDL_Condition *a),(a),)
SDL_DYNAPI_PROC(SDL_bool,SDL_CaptureMouse,(SDL_bool a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClaimWindowForGPUDevice,(SDL_GPUDevice *a, SDL_Window *b),(a,b),return)
SDL_DYNAPI_PROC(void,SDL_CleanupEnvironment,(void),(),)
SDL_DYNAPI_PROC(void,SDL_CleanupTLS,(void),(),)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClearAudioStream,(SDL_AudioStream *a),(a),return)
SDL_DYNAPI_PROC(SDL_bool,SDL_ClearClipboardData,(void),(),return)

View File

@ -66,7 +66,12 @@ SDL_Environment *SDL_GetEnvironment(void)
return SDL_environment;
}
void SDL_CleanupEnvironment(void)
SDL_bool SDL_InitEnvironment(void)
{
return (SDL_GetEnvironment() != NULL);
}
void SDL_QuitEnvironment(void)
{
SDL_Environment *env = SDL_environment;

24
src/stdlib/SDL_getenv_c.h Normal file
View File

@ -0,0 +1,24 @@
/*
Simple DirectMedia Layer
Copyright (C) 1997-2024 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
arising from the use of this software.
Permission is granted to anyone to use this software for any purpose,
including commercial applications, and to alter it and redistribute it
freely, subject to the following restrictions:
1. The origin of this software must not be misrepresented; you must not
claim that you wrote the original software. If you use this software
in a product, an acknowledgment in the product documentation would be
appreciated but is not required.
2. Altered source versions must be plainly marked as such, and must not be
misrepresented as being the original software.
3. This notice may not be removed or altered from any source distribution.
*/
#include "SDL_internal.h"
extern bool SDL_InitEnvironment(void);
extern void SDL_QuitEnvironment(void);