File tree Expand file tree Collapse file tree 2 files changed +17
-1
lines changed
sys/compat/linuxkpi/common/include/linux Expand file tree Collapse file tree 2 files changed +17
-1
lines changed Original file line number Diff line number Diff line change 11/*-
22 * SPDX-License-Identifier: BSD-2-Clause
33 *
4- * Copyright (c) 2024 The FreeBSD Foundation
4+ * Copyright (c) 2024-2025 The FreeBSD Foundation
55 *
66 * This software was developed by Björn Zeeb under sponsorship from
77 * the FreeBSD Foundation.
4343 guard_ ## _n ## _t guard_ ## _n ## _ ## __COUNTER__ \
4444 __cleanup(guard_ ## _n ## _destroy) = guard_ ## _n ## _create
4545
46+ #define DEFINE_FREE (_n , _t , _f ) \
47+ static inline void \
48+ __free_ ## _n(void *p) \
49+ { \
50+ _t _T; \
51+ \
52+ _T = *(_t *)p; \
53+ _f; \
54+ }
55+
56+ #define __free (_n ) __cleanup(__free_##_n)
57+
4658#endif /* _LINUXKPI_LINUX_CLEANUP_H */
Original file line number Diff line number Diff line change 4040#include <linux/compat.h>
4141#include <linux/types.h>
4242#include <linux/gfp.h>
43+ #include <linux/err.h>
4344#include <linux/llist.h>
4445#include <linux/overflow.h>
46+ #include <linux/cleanup.h>
4547
4648MALLOC_DECLARE (M_KMALLOC );
4749
@@ -153,6 +155,8 @@ kfree(const void *ptr)
153155 lkpi_kfree (ptr );
154156}
155157
158+ DEFINE_FREE (kfree , void * , if (!IS_ERR_OR_NULL (_T )) kfree (_T ))
159+
156160/*
157161 * Other k*alloc() funtions using the above as underlying allocator.
158162 */
You can’t perform that action at this time.
0 commit comments