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
0f3be0beb8e461428466172d4b7b800933038adb)
*** 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