tree-wide: rename unref_and_replace_full to unref_and_replace_new_ref

We have a number of *_unref_and_replace macros. One could think that
they are like the various free_and_replace variants, but they actually
create a new ref to the passed object. The free_and_replace variants
take ownership of the argument. This inconsistency is surprising. Rename
all those functions to have "_new_ref" at the end to make the difference
clear.
This commit is contained in:
Zbigniew Jędrzejewski-Szmek
2026-05-08 11:14:13 +02:00
parent 174f6f3595
commit 62a489fbf9
10 changed files with 21 additions and 21 deletions
+7 -7
View File
@@ -19,13 +19,13 @@ typedef void* (*mfree_func_t)(void *p);
/* This is similar to free_and_replace_full(), but NULL is not assigned to 'b', and its reference counter is
* increased. */
#define unref_and_replace_full(a, b, ref_func, unref_func) \
({ \
typeof(a)* _a = &(a); \
typeof(b) _b = ref_func(b); \
unref_func(*_a); \
*_a = _b; \
0; \
#define unref_and_replace_new_ref(a, b, ref_func, unref_func) \
({ \
typeof(a)* _a = &(a); \
typeof(b) _b = ref_func(b); \
unref_func(*_a); \
*_a = _b; \
0; \
})
#define _DEFINE_TRIVIAL_REF_FUNC(type, name, scope) \