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:
parent
b1f3682216
commit
e23257307e
51 changed files with 262 additions and 123 deletions
|
@ -134,6 +134,8 @@ extern SDL_DECLSPEC int SDLCALL SDL_GetNumCameraDrivers(void);
|
|||
* "coremedia" or "android". These never have Unicode characters, and are not
|
||||
* meant to be proper names.
|
||||
*
|
||||
* The returned string follows the SDL_GetStringRule.
|
||||
*
|
||||
* \param index the index of the camera driver; the value ranges from 0 to
|
||||
* SDL_GetNumCameraDrivers() - 1
|
||||
* \returns the name of the camera driver at the requested index, or NULL if
|
||||
|
@ -150,11 +152,11 @@ extern SDL_DECLSPEC const char *SDLCALL SDL_GetCameraDriver(int index);
|
|||
/**
|
||||
* Get the name of the current camera driver.
|
||||
*
|
||||
* The returned string points to internal static memory and thus never becomes
|
||||
* invalid, even if you quit the camera subsystem and initialize a new driver
|
||||
* (although such a case would return a different static string from another
|
||||
* call to this function, of course). As such, you should not modify or free
|
||||
* the returned string.
|
||||
* The names of drivers are all simple, low-ASCII identifiers, like "v4l2",
|
||||
* "coremedia" or "android". These never have Unicode characters, and are not
|
||||
* meant to be proper names.
|
||||
*
|
||||
* The returned string follows the SDL_GetStringRule.
|
||||
*
|
||||
* \returns the name of the current camera driver or NULL if no driver has
|
||||
* been initialized.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue