Removed temporary memory from the API

It was intended to make the API easier to use, but various automatic garbage collection all had flaws, and making the application periodically clean up temporary memory added cognitive load to using the API, and in many cases was it was difficult to restructure threaded code to handle this.

So, we're largely going back to the original system, where the API returns allocated results and you free them.

In addition, to solve the problems we originally wanted temporary memory for:
* Short strings with a finite count, like device names, get stored in a per-thread string pool.
* Events continue to use temporary memory internally, which is cleaned up on the next event processing cycle.
This commit is contained in:
Sam Lantinga
2024-07-26 18:57:18 -07:00
parent 21411c6418
commit 4f55271571
100 changed files with 737 additions and 853 deletions

View File

@@ -145,7 +145,7 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumCameraDrivers(void);
*
* \sa SDL_GetNumCameraDrivers
*/
extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetCameraDriver(int index);
extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraDriver(int index);
/**
* Get the name of the current camera driver.
@@ -161,7 +161,7 @@ extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetCameraDriver(int index);
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetCurrentCameraDriver(void);
extern SDL_DECLSPEC const char * SDLCALL SDL_GetCurrentCameraDriver(void);
/**
* Get a list of currently connected camera devices.
@@ -169,7 +169,7 @@ extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetCurrentCameraDriver(void);
* \param count a pointer filled in with the number of cameras returned, may
* be NULL.
* \returns a 0 terminated array of camera instance IDs or NULL on failure;
* call SDL_GetError() for more information.
* call SDL_GetError() for more information. This should be freed with SDL_free() when it is no longer needed.
*
* \threadsafety It is safe to call this function from any thread.
*
@@ -177,7 +177,7 @@ extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetCurrentCameraDriver(void);
*
* \sa SDL_OpenCamera
*/
extern SDL_DECLSPEC_TEMP const SDL_CameraID * SDLCALL SDL_GetCameras(int *count);
extern SDL_DECLSPEC_FREE SDL_CameraID * SDLCALL SDL_GetCameras(int *count);
/**
* Get the list of native formats/sizes a camera supports.
@@ -205,7 +205,7 @@ extern SDL_DECLSPEC_TEMP const SDL_CameraID * SDLCALL SDL_GetCameras(int *count)
* \param count a pointer filled in with the number of elements in the list,
* may be NULL.
* \returns a NULL terminated array of pointers to SDL_CameraSpec or NULL on
* failure; call SDL_GetError() for more information.
* failure; call SDL_GetError() for more information. This is a single allocation that should be freed with SDL_free() when it is no longer needed.
*
* \threadsafety It is safe to call this function from any thread.
*
@@ -214,7 +214,7 @@ extern SDL_DECLSPEC_TEMP const SDL_CameraID * SDLCALL SDL_GetCameras(int *count)
* \sa SDL_GetCameras
* \sa SDL_OpenCamera
*/
extern SDL_DECLSPEC_TEMP const SDL_CameraSpec * const * SDLCALL SDL_GetCameraSupportedFormats(SDL_CameraID devid, int *count);
extern SDL_DECLSPEC_FREE SDL_CameraSpec ** SDLCALL SDL_GetCameraSupportedFormats(SDL_CameraID devid, int *count);
/**
* Get the human-readable device name for a camera.
@@ -229,7 +229,7 @@ extern SDL_DECLSPEC_TEMP const SDL_CameraSpec * const * SDLCALL SDL_GetCameraSup
*
* \sa SDL_GetCameras
*/
extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetCameraName(SDL_CameraID instance_id);
extern SDL_DECLSPEC const char * SDLCALL SDL_GetCameraName(SDL_CameraID instance_id);
/**
* Get the position of the camera in relation to the system.