mirror of
https://github.com/xen-project/xen.git
synced 2026-10-28 10:11:27 +01:00
xen: Swap order of actions in the FREE*() macros
Wherever possible, it is a good idea to NULL out the visible reference to an object prior to freeing it. The FREE*() macros already collect together both parts, making it easy to adjust. This has a marginal code generation improvement, as some of the calls to the free() function can be tailcall optimised. No functional change. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
1 parent
fb5b6f6744
commit
c4f427ec87
2 files changed
+6
-4
No files matched your search
@@ -93,8 +93,9 @@ bool scrub_free_pages(void);
|
||||
|
||||
/* Free an allocation, and zero the pointer to it. */
|
||||
#define FREE_XENHEAP_PAGES(p, o) do { \
|
||||
free_xenheap_pages(p, o); \
|
||||
void *_ptr_ = (p); \
|
||||
(p) = NULL; \
|
||||
free_xenheap_pages(_ptr_, o); \
|
||||
} while ( false )
|
||||
#define FREE_XENHEAP_PAGE(p) FREE_XENHEAP_PAGES(p, 0)
|
||||
|
||||
|
||||
@@ -66,9 +66,10 @@
|
||||
extern void xfree(void *p);
|
||||
|
||||
/* Free an allocation, and zero the pointer to it. */
|
||||
#define XFREE(p) do { \
|
||||
xfree(p); \
|
||||
(p) = NULL; \
|
||||
#define XFREE(p) do { \
|
||||
void *_ptr_ = (p); \
|
||||
(p) = NULL; \
|
||||
xfree(_ptr_); \
|
||||
} while ( false )
|
||||
|
||||
/* Underlying functions */
|
||||
|
||||