]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
cleanup: introduce DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO_RENAME() macro
authorYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 25 Oct 2025 01:21:54 +0000 (10:21 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sat, 25 Oct 2025 01:22:16 +0000 (10:22 +0900)
This is similar to DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(), but for
macro.

src/fundamental/cleanup-fundamental.h

index 8a8c40ad0646c5de67b7e1efa4cac3dac9d12b92..86b9851fd54ab4e58343b0b4d7e00ca9c47d76b3 100644 (file)
         DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_RENAME(type, func, func##p, empty)
 
 /* When func() doesn't return the appropriate type, and is also a macro, set variable to empty afterwards. */
-#define DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO(type, func, empty)       \
-        static inline void func##p(type *p) {                           \
+#define DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO_RENAME(type, macro, name, empty) \
+        static inline void name(type *p) {                              \
                 if (*p != (empty)) {                                    \
-                        func(*p);                                       \
+                        macro(*p);                                      \
                         *p = (empty);                                   \
                 }                                                       \
         }
 
+#define DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO(type, macro, empty)      \
+        DEFINE_TRIVIAL_CLEANUP_FUNC_FULL_MACRO_RENAME(type, macro, macro##p, empty)
+
 typedef void (*free_array_func_t)(void *p, size_t n);
 
 /* An automatic _cleanup_-like logic for destroy arrays (i.e. pointers + size) when leaving scope */