macros: add support for GNUC cleanup __attribute__
authorRyan Lortie <desrt@desrt.ca>
Wed, 28 Jan 2015 11:27:35 +0000 (11:27 +0000)
committerRyan Lortie <desrt@desrt.ca>
Fri, 30 Jan 2015 15:49:53 +0000 (16:49 +0100)
commit2596919c58a364243196e65a9adda693448139f7
tree28ac4da9a2b9a2d9fb27f5a218a39e4abd68a4ee
parentb5e1ea6fee6ac5b97585ffc1e30eb4f1ec137e1f
macros: add support for GNUC cleanup __attribute__

Add g_auto() and g_autoptr() as helpers for declaring variables with
automatic cleanup.

Add some macros to help types define cleanup functions for themselves.

Going forward it will be an expectation that people use this macro when
creating a new type, even if they do not intend to use the auto-cleanup
functionality for themselves.

These new macros only work on GCC and clang, which is why we resisted
adding them for so long.  There exist many people who are only
interested in writing programs for these compilers, however, and a
similar API in libgsystem has proven to be extremely popular, so let's
expose this functionality to an even wider audience.

We ignore deprecation warnings when emitting the free functions, which
seems suspicious.  The reason that we do this is not because we want to
call deprecated functions, but just the opposite: sometimes the free
function will be an _unref() function that is only AVAILABLE_IN newer
versions, and these warnings are also implemented as deprecation
warnings.

https://bugzilla.gnome.org/show_bug.cgi?id=743640
docs/reference/glib/glib-sections.txt
glib/docs.c
glib/gmacros.h