Namespace and share DEFINE_TRIVIAL_CLEANUP_FUNC via. rpmostree-util.h

This commit is contained in:
James Antill 2014-07-11 02:07:31 -04:00
parent b7dbabe065
commit 0e7ba9077f
3 changed files with 13 additions and 19 deletions

View File

@ -51,13 +51,6 @@ static GOptionEntry option_entries[] = {
{ NULL }
};
/* FIXME: merge and put into libgsystem or rpmostree-utils */
#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
static inline void func##p(type *p) { \
if (*p) \
func(*p); \
} \
struct __useless_struct_to_allow_trailing_semicolon__
static void
header_free_p (gpointer data)
@ -521,7 +514,7 @@ rpmrev_free (struct RpmRevisionData *ptr)
g_free (ptr);
}
DEFINE_TRIVIAL_CLEANUP_FUNC(struct RpmRevisionData *, rpmrev_free);
_RPMOSTREE_DEFINE_TRIVIAL_CLEANUP_FUNC(struct RpmRevisionData *, rpmrev_free);
#define _cleanup_rpmrev_ __attribute__((cleanup(rpmrev_freep)))

View File

@ -23,6 +23,7 @@
#include "string.h"
#include "rpmostree-treepkgdiff.h"
#include "rpmostree-util.h"
#include <ostree.h>
#include <hawkey/packagelist.h>
@ -36,17 +37,9 @@
#include "libgsystem.h"
/* Todo: move this to libgsystem */
#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
static inline void func##p(type *p) { \
if (*p) \
func(*p); \
} \
struct __useless_struct_to_allow_trailing_semicolon__
DEFINE_TRIVIAL_CLEANUP_FUNC(HySack, hy_sack_free);
DEFINE_TRIVIAL_CLEANUP_FUNC(HyQuery, hy_query_free);
DEFINE_TRIVIAL_CLEANUP_FUNC(HyPackageList, hy_packagelist_free);
_RPMOSTREE_DEFINE_TRIVIAL_CLEANUP_FUNC(HySack, hy_sack_free);
_RPMOSTREE_DEFINE_TRIVIAL_CLEANUP_FUNC(HyQuery, hy_query_free);
_RPMOSTREE_DEFINE_TRIVIAL_CLEANUP_FUNC(HyPackageList, hy_packagelist_free);
#define _cleanup_hysack_ __attribute__((cleanup(hy_sack_freep)))
#define _cleanup_hyquery_ __attribute__((cleanup(hy_query_freep)))

View File

@ -22,6 +22,14 @@
#include <gio/gio.h>
#define _RPMOSTREE_DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
static inline void func##p(type *p) { \
if (*p) \
func(*p); \
} \
struct __useless_struct_to_allow_trailing_semicolon__
gboolean
_rpmostree_util_enumerate_directory_allow_noent (GFile *dirpath,
const char *queryargs,