From d5f61043351ff1c0bea650873ec2541e1ede1f0a Mon Sep 17 00:00:00 2001 From: Krzesimir Nowak Date: Fri, 13 May 2016 08:08:49 +0200 Subject: [PATCH] build: Allow ostree to use g_autoptr on its types internally As an example, I g_autoptred one OstreeRepo in the "ostree init" command. Closes: #295 Approved by: cgwalters --- Makefile.am | 1 + src/libostree/ostree-autocleanups.h | 5 ++++- src/ostree/ot-builtin-init.c | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index a003af25..1de31544 100644 --- a/Makefile.am +++ b/Makefile.am @@ -24,6 +24,7 @@ AM_CPPFLAGS += -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \ -DLOCALEDIR=\"$(datadir)/locale\" -DSYSCONFDIR=\"$(sysconfdir)\" \ -DSHORTENED_SYSCONFDIR=\"$(shortened_sysconfdir)\" \ -DOSTREE_FEATURES='"$(OSTREE_FEATURES)"' \ + -DOSTREE_COMPILATION \ -DG_LOG_DOMAIN=\"OSTree\" \ -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 -DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_40 \ -DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_40 -DSOUP_VERSION_MAX_ALLOWED=SOUP_VERSION_2_48 diff --git a/src/libostree/ostree-autocleanups.h b/src/libostree/ostree-autocleanups.h index d04ba9aa..7301ef1d 100644 --- a/src/libostree/ostree-autocleanups.h +++ b/src/libostree/ostree-autocleanups.h @@ -30,7 +30,10 @@ G_BEGIN_DECLS #define OSTREE_WITH_AUTOCLEANUPS 0 #endif -#if OSTREE_WITH_AUTOCLEANUPS && GLIB_CHECK_VERSION(2, 44, 0) +/* ostree can use g_autoptr backports from libglnx when glib is too + * old, but still avoid exposing them to users that also have an old + * glib */ +#if defined(OSTREE_COMPILATION) || (OSTREE_WITH_AUTOCLEANUPS && GLIB_CHECK_VERSION(2, 44, 0)) /* * The following types have no specific clear/free/unref functions, so diff --git a/src/ostree/ot-builtin-init.c b/src/ostree/ot-builtin-init.c index 9e7c8a2b..a250b793 100644 --- a/src/ostree/ot-builtin-init.c +++ b/src/ostree/ot-builtin-init.c @@ -37,7 +37,7 @@ gboolean ostree_builtin_init (int argc, char **argv, GCancellable *cancellable, GError **error) { GOptionContext *context = NULL; - glnx_unref_object OstreeRepo *repo = NULL; + g_autoptr(OstreeRepo) repo = NULL; gboolean ret = FALSE; OstreeRepoMode mode;