3 ms·
GLib also provides macros that use autocleanup.[0] Using a bunch of macro magic, they allow you to write `g_autoptr(GPtrArray) arr = ...` to automatically unre
by sp1rit 2y ago
GLib also provides macros that use autocleanup.[0]
Using a bunch of macro magic, they allow you to write `g_autoptr(GPtrArray) arr = ...` to automatically unref arr when the scipe exits.
One footgun that autocleanup has and C++ smart pointers don't is, that the cleanup function isn't called on reassignment, so reassigning on a autoptr causes the previous value to leak.
[0]:https://docs.gtk.org/glib/auto-cleanup.html https://docs.gtk.org/glib/auto-cleanup.html