mirror of
https://github.com/systemd/systemd.git
synced 2026-08-04 15:10:33 +00:00
alloc-util: make mfree() typesafe
Make sure we return the same type as we accept. One incorrect use of mfree() is discovered and fixed this way.
This commit is contained in:
committed by
Yu Watanabe
parent
76f226d71b
commit
5afcf89ca2
@@ -44,10 +44,11 @@ typedef void (*free_func_t)(void *p);
|
||||
|
||||
#define malloc0(n) (calloc(1, (n) ?: 1))
|
||||
|
||||
static inline void *mfree(void *memory) {
|
||||
free(memory);
|
||||
return NULL;
|
||||
}
|
||||
#define mfree(memory) \
|
||||
({ \
|
||||
free(memory); \
|
||||
(typeof(memory)) NULL; \
|
||||
})
|
||||
|
||||
#define free_and_replace(a, b) \
|
||||
({ \
|
||||
|
||||
Reference in New Issue
Block a user