-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Should destroy functions take pointer to pointer? #10071
Comments
Vaguely sounds like microsoft's oh-so-very-safe crt apis? I'm not strongly objecting but do we really need this? |
Hard no from me. |
Fair enough. It would probably also make language bindings harder. |
The convention used in e.g. GLib and libdbus is that destroy/free/unref functions take the pointer like they do in SDL2, but for authors of C code it's extremely convenient to have a macro that implements this pattern (shown here as pseudocode using GLib's naming convention):
For example GLib has this for GObject subclasses as the pair CPython This is particularly convenient for users of compilers implementing gcc-compatible |
Hmmmmm, we do know the type of the pointer in SDL3 now, we could potentially implement |
Actually, no, that wouldn't work well. You'd have to cast your argument to |
It would have to be It might be better to have the equivalent of what libdbus does:
which is used like this:
The implementation was https://gitlab.freedesktop.org/dbus/dbus/-/commit/e13f29cae788ee0d0d16352c9be2d9e14a5a0b3d, © 2017 Collabora Ltd. and I'm happy to license it under the Zlib license if you want. |
Can we use |
What do you guys think about having the destroy functions take a pointer to an object pointer, so it can automatically NULL it out?
e.g.
@libsdl-org/a-team, @smcv, thoughts?
The text was updated successfully, but these errors were encountered: