Merge branch 'master' into 'master'

macros: Double-cast func for g_autolist to avoid warning

Closes #1382 and #1390

See merge request GNOME/glib!8
This commit is contained in:
Philip Withnall 2018-05-25 13:13:33 +00:00
commit 89c6d64a97
2 changed files with 9 additions and 3 deletions

View File

@ -482,9 +482,9 @@
typedef GList *_GLIB_AUTOPTR_LIST_TYPENAME(TypeName); \ typedef GList *_GLIB_AUTOPTR_LIST_TYPENAME(TypeName); \
typedef GSList *_GLIB_AUTOPTR_SLIST_TYPENAME(TypeName); \ typedef GSList *_GLIB_AUTOPTR_SLIST_TYPENAME(TypeName); \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \
static inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); } \ static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_FUNC_NAME(TypeName) (TypeName **_ptr) { if (*_ptr) (func) (*_ptr); } \
static inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) { g_list_free_full (*_l, (GDestroyNotify) func); } \ static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_LIST_FUNC_NAME(TypeName) (GList **_l) { g_list_free_full (*_l, (GDestroyNotify) (void(*)(void)) func); } \
static inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) { g_slist_free_full (*_l, (GDestroyNotify) func); } \ static G_GNUC_UNUSED inline void _GLIB_AUTOPTR_SLIST_FUNC_NAME(TypeName) (GSList **_l) { g_slist_free_full (*_l, (GDestroyNotify) (void(*)(void)) func); } \
G_GNUC_END_IGNORE_DEPRECATIONS G_GNUC_END_IGNORE_DEPRECATIONS
#define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \ #define G_DEFINE_AUTO_CLEANUP_CLEAR_FUNC(TypeName, func) \
G_GNUC_BEGIN_IGNORE_DEPRECATIONS \ G_GNUC_BEGIN_IGNORE_DEPRECATIONS \

View File

@ -1,6 +1,12 @@
#include <glib.h> #include <glib.h>
#include <string.h> #include <string.h>
typedef struct _HNVC HasNonVoidCleanup;
HasNonVoidCleanup * non_void_cleanup (HasNonVoidCleanup *);
/* Should not cause any warnings with -Wextra */
G_DEFINE_AUTOPTR_CLEANUP_FUNC(HasNonVoidCleanup, non_void_cleanup)
static void static void
test_autofree (void) test_autofree (void)
{ {