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:
@@ -57,7 +57,7 @@ test_multi_audio(SDL_AudioDeviceID *devices, int devcount)
|
||||
#endif
|
||||
|
||||
for (i = 0; i < devcount; i++) {
|
||||
char *devname = SDL_GetAudioDeviceName(devices[i]);
|
||||
const char *devname = SDL_GetAudioDeviceName(devices[i]);
|
||||
|
||||
SDL_Log("Playing on device #%d of %d: id=%u, name='%s'...", i, devcount, (unsigned int) devices[i], devname);
|
||||
|
||||
@@ -82,7 +82,6 @@ test_multi_audio(SDL_AudioDeviceID *devices, int devcount)
|
||||
SDL_Log("done.");
|
||||
SDL_DestroyAudioStream(stream);
|
||||
}
|
||||
SDL_free(devname);
|
||||
stream = NULL;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user