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:
@@ -365,7 +365,7 @@ static int audio_enumerateAndNameAudioDevices(void *arg)
|
||||
{
|
||||
int t;
|
||||
int i, n;
|
||||
char *name;
|
||||
const char *name;
|
||||
SDL_AudioDeviceID *devices = NULL;
|
||||
|
||||
/* Iterate over types: t=0 output device, t=1 input/capture device */
|
||||
@@ -385,7 +385,6 @@ static int audio_enumerateAndNameAudioDevices(void *arg)
|
||||
SDLTest_AssertCheck(name != NULL, "Verify result from SDL_GetAudioDeviceName(%i) is not NULL", i);
|
||||
if (name != NULL) {
|
||||
SDLTest_AssertCheck(name[0] != '\0', "verify result from SDL_GetAudioDeviceName(%i) is not empty, got: '%s'", i, name);
|
||||
SDL_free(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user