Skip to content
Snippets Groups Projects
Verified Commit 9ae60d6d authored by Vladimír Čunát's avatar Vladimír Čunát Committed by Tomas Krizek
Browse files

contrib/cleanup: loosen type-checking in auto_free

- 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.
parent 15b7255e
Branches
Tags
1 merge request!1100contrib/cleanup: loosen type-checking in auto_free
Pipeline #73260 failed with stages
in 1 hour, 6 minutes, and 43 seconds
......@@ -11,8 +11,8 @@
#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) {
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment