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

@@ -160,15 +160,12 @@ extern SDL_DECLSPEC const SDL_SensorID * SDLCALL SDL_GetSensors(int *count);
*
* This can be called before any sensors are opened.
*
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param instance_id the sensor instance ID.
* \returns the sensor name, or NULL if `instance_id` is not valid.
*
* \since This function is available since SDL 3.0.0.
*/
extern SDL_DECLSPEC const char * SDLCALL SDL_GetSensorNameForID(SDL_SensorID instance_id);
extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetSensorNameForID(SDL_SensorID instance_id);
/**
* Get the type of a sensor.
@@ -232,16 +229,13 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetSensorProperties(SDL_Sensor
/**
* Get the implementation dependent name of a sensor.
*
* This returns temporary memory which will be automatically freed later, and
* can be claimed with SDL_ClaimTemporaryMemory().
*
* \param sensor the SDL_Sensor object.
* \returns the sensor 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_GetSensorName(SDL_Sensor *sensor);
extern SDL_DECLSPEC_TEMP const char * SDLCALL SDL_GetSensorName(SDL_Sensor *sensor);
/**
* Get the type of a sensor.