- advantage: `auto_free anyType *foo;` works (for anyType != char)
- disadvantage: `auto_free anyType bar;` is also accepted,
though I expect such problems will be relatively easy to debug.
#include <stdlib.h>
#define auto_free __attribute__((cleanup(_cleanup_free)))
-static inline void _cleanup_free(char **p) {
- free(*p);
+static inline void _cleanup_free(const void *p) {
+ free(*(char **)p);
}
#define auto_close __attribute__((cleanup(_cleanup_close)))
static inline void _cleanup_close(int *p) {