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

@@ -63,14 +63,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetClipboardText(const char *text);
* a copy of the clipboard's content.
*
* \returns the clipboard text on success or an empty string on failure; call
* SDL_GetError() for more information.
* SDL_GetError() for more information. This should be freed with SDL_free() when it is no longer needed.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_HasClipboardText
* \sa SDL_SetClipboardText
*/
extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetClipboardText(void);
extern SDL_DECLSPEC_FREE char * SDLCALL SDL_GetClipboardText(void);
/**
* Query whether the clipboard exists and contains a non-empty text string.
@@ -105,14 +105,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_SetPrimarySelectionText(const char *text);
* a copy of the primary selection's content.
*
* \returns the primary selection text on success or an empty string on
* failure; call SDL_GetError() for more information.
* failure; call SDL_GetError() for more information. This should be freed with SDL_free() when it is no longer needed.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_HasPrimarySelectionText
* \sa SDL_SetPrimarySelectionText
*/
extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetPrimarySelectionText(void);
extern SDL_DECLSPEC_FREE char * SDLCALL SDL_GetPrimarySelectionText(void);
/**
* Query whether the primary selection exists and contains a non-empty text
@@ -215,14 +215,14 @@ extern SDL_DECLSPEC int SDLCALL SDL_ClearClipboardData(void);
* \param mime_type the mime type to read from the clipboard.
* \param size a pointer filled in with the length of the returned data.
* \returns the retrieved data buffer or NULL on failure; call SDL_GetError()
* for more information.
* for more information. This should be freed with SDL_free() when it is no longer needed.
*
* \since This function is available since SDL 3.0.0.
*
* \sa SDL_HasClipboardData
* \sa SDL_SetClipboardData
*/
extern SDL_DECLSPEC_TEMP const void * SDLCALL SDL_GetClipboardData(const char *mime_type, size_t *size);
extern SDL_DECLSPEC_FREE void * SDLCALL SDL_GetClipboardData(const char *mime_type, size_t *size);
/**
* Query whether there is data in the clipboard for the provided mime type.