Introduce formal policy for APIs that return strings.
This declares that any `const char *` returned from SDL is owned by SDL, and promises to be valid _at least_ until the next time the event queue runs, or SDL_Quit() is called, even if the thing that owns the string gets destroyed or changed before then. This is noted in the headers as "the SDL_GetStringRule", so this will both be greppable to find a detailed explaination in docs/README-strings.md and wikiheaders will automatically turn it into a link we can point at the appropriate documentation. Fixes #9902. (and several FIXMEs, both known and yet-undocumented.)
This commit is contained in:
@@ -231,6 +231,8 @@ extern SDL_DECLSPEC SDL_JoystickID *SDLCALL SDL_GetJoysticks(int *count);
|
||||
*
|
||||
* This can be called before any joysticks are opened.
|
||||
*
|
||||
* The returned string follows the SDL_GetStringRule.
|
||||
*
|
||||
* \param instance_id the joystick instance ID
|
||||
* \returns the name of the selected joystick. If no name can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
@@ -247,6 +249,8 @@ extern SDL_DECLSPEC const char *SDLCALL SDL_GetJoystickInstanceName(SDL_Joystick
|
||||
*
|
||||
* This can be called before any joysticks are opened.
|
||||
*
|
||||
* The returned string follows the SDL_GetStringRule.
|
||||
*
|
||||
* \param instance_id the joystick instance ID
|
||||
* \returns the path of the selected joystick. If no path can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
@@ -669,6 +673,8 @@ extern SDL_DECLSPEC SDL_PropertiesID SDLCALL SDL_GetJoystickProperties(SDL_Joyst
|
||||
/**
|
||||
* Get the implementation dependent name of a joystick.
|
||||
*
|
||||
* The returned string follows the SDL_GetStringRule.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
|
||||
* \returns the name of the selected joystick. If no name can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
@@ -682,6 +688,8 @@ extern SDL_DECLSPEC const char *SDLCALL SDL_GetJoystickName(SDL_Joystick *joysti
|
||||
/**
|
||||
* Get the implementation dependent path of a joystick.
|
||||
*
|
||||
* The returned string follows the SDL_GetStringRule.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
|
||||
* \returns the path of the selected joystick. If no path can be found, this
|
||||
* function returns NULL; call SDL_GetError() for more information.
|
||||
@@ -799,6 +807,8 @@ extern SDL_DECLSPEC Uint16 SDLCALL SDL_GetJoystickFirmwareVersion(SDL_Joystick *
|
||||
*
|
||||
* Returns the serial number of the joystick, or NULL if it is not available.
|
||||
*
|
||||
* The returned string follows the SDL_GetStringRule.
|
||||
*
|
||||
* \param joystick the SDL_Joystick obtained from SDL_OpenJoystick()
|
||||
* \returns the serial number of the selected joystick, or NULL if
|
||||
* unavailable.
|
||||
|
||||
Reference in New Issue
Block a user