Hacker News new | ask | show | jobs
by sp1rit 762 days 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