[9.20] 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.20' into 'bind-9.20'

See merge request isc-projects/bind9!11736
This commit is contained in:
Ondřej Surý 2026-03-23 12:05:40 +01:00
commit 13a656f79a

View file

@ -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