mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
Add MOVE_OWNERSHIP() macro for transferring pointer ownership
A helper macro that returns the current value of a pointer and sets
it to NULL in one expression, useful for transferring ownership in
designated initializers.
(cherry picked from commit 0f3be0beb8)
This commit is contained in:
parent
208f1fcfec
commit
8feefb9874
1 changed files with 7 additions and 0 deletions
|
|
@ -41,6 +41,13 @@
|
|||
*** General Macros.
|
||||
***/
|
||||
|
||||
#define MOVE_OWNERSHIP(source) \
|
||||
({ \
|
||||
__typeof__(source) __ownership = (source); \
|
||||
(source) = NULL; \
|
||||
__ownership; \
|
||||
})
|
||||
|
||||
/*%
|
||||
* Legacy way how to hide unused function arguments, don't use in
|
||||
* the new code, rather use the ISC_ATTR_UNUSED macro that expands
|
||||
|
|
|
|||
Loading…
Reference in a new issue