From a2341f6836da0a217ab0c5f2b82f0c4ea13d429d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 17 Jan 2015 23:20:00 -0500 Subject: [PATCH] Move DEFINE_TRIVIAL_CLEANUP_FUNC to macro.h This remove the need for various header files to include the (relatively heavyweight) util.h. --- src/console/consoled.h | 2 -- src/import/import-raw.h | 2 +- src/journal/journal-file.h | 2 +- src/shared/macro.h | 7 +++++++ src/shared/set.h | 2 +- src/shared/util.h | 7 ------- 6 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/console/consoled.h b/src/console/consoled.h index f8a3df4487d..b0db610400b 100644 --- a/src/console/consoled.h +++ b/src/console/consoled.h @@ -26,7 +26,6 @@ #include #include #include "grdev.h" -#include "hashmap.h" #include "idev.h" #include "list.h" #include "macro.h" @@ -36,7 +35,6 @@ #include "sysview.h" #include "term.h" #include "unifont.h" -#include "util.h" typedef struct Manager Manager; typedef struct Session Session; diff --git a/src/import/import-raw.h b/src/import/import-raw.h index 5a38cdcc9e5..a423ec0187a 100644 --- a/src/import/import-raw.h +++ b/src/import/import-raw.h @@ -20,7 +20,7 @@ ***/ #include "sd-event.h" -#include "util.h" +#include "macro.h" typedef struct RawImport RawImport; diff --git a/src/journal/journal-file.h b/src/journal/journal-file.h index 6812385e1ef..2526e14d650 100644 --- a/src/journal/journal-file.h +++ b/src/journal/journal-file.h @@ -31,7 +31,7 @@ #include "sparse-endian.h" #include "journal-def.h" -#include "util.h" +#include "macro.h" #include "mmap-cache.h" #include "hashmap.h" diff --git a/src/shared/macro.h b/src/shared/macro.h index daa42c4c681..96d96f96211 100644 --- a/src/shared/macro.h +++ b/src/shared/macro.h @@ -446,4 +446,11 @@ do { \ #define GID_INVALID ((gid_t) -1) #define MODE_INVALID ((mode_t) -1) +#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__ + #include "log.h" diff --git a/src/shared/set.h b/src/shared/set.h index 4605ecd2c17..2b49e2f2870 100644 --- a/src/shared/set.h +++ b/src/shared/set.h @@ -22,7 +22,7 @@ ***/ #include "hashmap.h" -#include "util.h" +#include "macro.h" Set *internal_set_new(const struct hash_ops *hash_ops HASHMAP_DEBUG_PARAMS); #define set_new(ops) internal_set_new(ops HASHMAP_DEBUG_SRC_ARGS) diff --git a/src/shared/util.h b/src/shared/util.h index 5818fee82e5..8a3e95a17aa 100644 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -664,13 +664,6 @@ static inline void freep(void *p) { free(*(void**) p); } -#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 inline void closep(int *fd) { safe_close(*fd); }