mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-09-17 08:48:12 +00:00
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:
@@ -299,9 +299,7 @@ void SDL_RunThread(SDL_Thread *thread)
|
||||
if (!SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_ALIVE, SDL_THREAD_STATE_ZOMBIE)) {
|
||||
/* Clean up if something already detached us. */
|
||||
if (SDL_AtomicCompareAndSwap(&thread->state, SDL_THREAD_STATE_DETACHED, SDL_THREAD_STATE_CLEANED)) {
|
||||
if (thread->name) {
|
||||
SDL_free(thread->name);
|
||||
}
|
||||
SDL_FreeLater(thread->name);
|
||||
SDL_free(thread);
|
||||
}
|
||||
}
|
||||
@@ -421,9 +419,7 @@ void SDL_WaitThread(SDL_Thread *thread, int *status)
|
||||
if (status) {
|
||||
*status = thread->status;
|
||||
}
|
||||
if (thread->name) {
|
||||
SDL_free(thread->name);
|
||||
}
|
||||
SDL_FreeLater(thread->name);
|
||||
SDL_free(thread);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user