mirror of
https://github.com/isc-projects/bind9.git
synced 2026-05-28 04:34:54 -04:00
[9.18] new: dev: 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. Backport of MR !11724 Merge branch 'backport-ondrej/TAKE_OWNERSHIP-macro-9.18' into 'bind-9.18' See merge request isc-projects/bind9!11737
This commit is contained in:
commit
d783ac4a47
1 changed files with 7 additions and 0 deletions
|
|
@ -47,6 +47,13 @@
|
|||
*** General Macros.
|
||||
***/
|
||||
|
||||
#define MOVE_OWNERSHIP(source) \
|
||||
({ \
|
||||
__typeof__(source) __ownership = (source); \
|
||||
(source) = NULL; \
|
||||
__ownership; \
|
||||
})
|
||||
|
||||
/*%
|
||||
* Use this to hide unused function arguments.
|
||||
* \code
|
||||
|
|
|
|||
Loading…
Reference in a new issue