Don't automatically free temporary memory, let the application call SDL_FreeTemporaryMemory() when it's ready.

Also mark up all functions that return temporary memory with SDL_DECLSPEC_TEMP, to help people implementing language bindings.

Fixes https://github.com/libsdl-org/SDL/issues/10378
This commit is contained in:
Sam Lantinga
2024-07-26 06:05:57 -07:00
parent 2f38a4bf5e
commit 5e513ecc7f
31 changed files with 124 additions and 402 deletions

View File

@@ -83,9 +83,6 @@ typedef struct SDL_Finger
* Therefore the returned list might be empty, although devices are available.
* After using all devices at least once the number will be correct.
*
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param count a pointer filled in with the number of devices returned, may
* be NULL.
* \returns a 0 terminated array of touch device IDs or NULL on failure; call
@@ -93,21 +90,18 @@ typedef struct SDL_Finger
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC const SDL_TouchID * SDLCALL SDL_GetTouchDevices(int *count);
extern SDL_DECLSPEC_TEMP const SDL_TouchID * SDLCALL SDL_GetTouchDevices(int *count);
/**
* Get the touch device name as reported from the driver.
*
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param touchID the touch device instance ID.
* \returns touch device name, or NULL on failure; call SDL_GetError() for
* more information.
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC const char * SDLCALL SDL_GetTouchDeviceName(SDL_TouchID touchID);
extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetTouchDeviceName(SDL_TouchID touchID);
/**
* Get the type of the given touch device.
@@ -122,9 +116,6 @@ extern SDL_DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_Touch
/**
* Get a list of active fingers for a given touch device.
*
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param touchID the ID of a touch device.
* \param count a pointer filled in with the number of fingers returned, can
* be NULL.
@@ -133,7 +124,7 @@ extern SDL_DECLSPEC SDL_TouchDeviceType SDLCALL SDL_GetTouchDeviceType(SDL_Touch
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC const SDL_Finger * const * SDLCALL SDL_GetTouchFingers(SDL_TouchID touchID, int *count);
extern SDL_DECLSPEC_TEMP const SDL_Finger * const * SDLCALL SDL_GetTouchFingers(SDL_TouchID touchID, int *count);
/* Ends C function definitions when using C++ */
#ifdef __cplusplus