Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce formal policy for APIs that return strings. #9944

Merged
merged 1 commit into from
Jun 3, 2024

Conversation

icculus
Copy link
Collaborator

@icculus icculus commented Jun 2, 2024

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.)

@icculus icculus added this to the 3.0 ABI milestone Jun 2, 2024
@icculus icculus requested a review from slouken June 2, 2024 02:27
Copy link
Collaborator

@slouken slouken left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I expected to come back with a bunch of concerns, but this is in all ways an improvement over the current state of things.

Thanks!

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 libsdl-org#9902.

(and several FIXMEs, both known and yet-undocumented.)
@icculus icculus force-pushed the sdl3-strings-use-event-memory branch from e7b9d0f to dbd0af7 Compare June 3, 2024 04:45
@icculus icculus merged commit e232573 into libsdl-org:main Jun 3, 2024
39 checks passed
@icculus icculus deleted the sdl3-strings-use-event-memory branch June 3, 2024 18:20
@icculus
Copy link
Collaborator Author

icculus commented Jun 3, 2024

sdl2-compat updated in libsdl-org/sdl2-compat@841d8ef for SDL_GetAudioDeviceName API change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SDL_GetAudioDeviceName() returns a strdup'd pointer, nothing else does.
2 participants