chiark / gitweb /
Move DEFINE_TRIVIAL_CLEANUP_FUNC to macro.h
[elogind.git] / src / shared / macro.h
index daa42c4c68101ce5e70fb773a7fafd5937c417e8..96d96f962116d0fdcce5c264a57e1c874c0d5fbe 100644 (file)
@@ -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"