--- libkmod/libkmod-util.h | 7 +++++++ libkmod/macro.h | 1 + 2 files changed, 8 insertions(+) diff --git a/libkmod/libkmod-util.h b/libkmod/libkmod-util.h index 8a70aeb..bc1ed4d 100644 --- a/libkmod/libkmod-util.h +++ b/libkmod/libkmod-util.h @@ -3,6 +3,7 @@ #include <limits.h> #include <stdbool.h> +#include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> @@ -56,3 +57,9 @@ static _always_inline_ unsigned int ALIGN_POWER2(unsigned int u) { return 1 << ((sizeof(u) * 8) - __builtin_clz(u - 1)); } + +static inline void freep(void *p) { + free(*(void**) p); +} + +#define _cleanup_free_ _cleanup_(freep) diff --git a/libkmod/macro.h b/libkmod/macro.h index 7969072..5396598 100644 --- a/libkmod/macro.h +++ b/libkmod/macro.h @@ -57,3 +57,4 @@ #define _printf_format_(a,b) __attribute__((format (printf, a, b))) #define _unused_ __attribute__((unused)) #define _always_inline_ __inline__ __attribute__((always_inline)) +#define _cleanup_(x) __attribute__((cleanup(x))) -- 1.8.4.2 -- To unsubscribe from this list: send the line "unsubscribe linux-modules" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html