backports: g_autofree

This commit is contained in:
Colin Walters
2015-02-25 21:44:42 -05:00
parent 1288bd8508
commit 37082ed867
2 changed files with 10 additions and 1 deletions

View File

@@ -21,7 +21,15 @@
#include <glnx-backport-autoptr.h>
#if !GLIB_CHECK_VERSION(2, 43, 3)
#if !GLIB_CHECK_VERSION(2, 43, 4)
static inline void
g_autoptr_cleanup_generic_gfree (void *p)
{
void **pp = (void**)p;
if (*pp)
g_free (*pp);
}
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GAsyncQueue, g_async_queue_unref)
G_DEFINE_AUTOPTR_CLEANUP_FUNC(GBookmarkFile, g_bookmark_file_free)

View File

@@ -55,6 +55,7 @@ G_BEGIN_DECLS
G_GNUC_END_IGNORE_DEPRECATIONS
#define g_autoptr(TypeName) _GLIB_CLEANUP(_GLIB_AUTOPTR_FUNC_NAME(TypeName)) _GLIB_AUTOPTR_TYPENAME(TypeName)
#define g_auto(TypeName) _GLIB_CLEANUP(_GLIB_AUTO_FUNC_NAME(TypeName)) TypeName
#define g_autofree _GLIB_CLEANUP(g_autoptr_cleanup_generic_gfree)
/**
* g_steal_pointer: