glib-aux: add nm_ref_string_reset() helper

This commit is contained in:
Thomas Haller 2022-09-26 16:30:25 +02:00
parent a1adfccf8a
commit 0b6a9e2c88
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -93,6 +93,23 @@ nm_ref_string_unref(NMRefString *rstr)
NM_AUTO_DEFINE_FCN_VOID(NMRefString *, _nm_auto_ref_string, nm_ref_string_unref);
#define nm_auto_ref_string nm_auto(_nm_auto_ref_string)
static inline gboolean
nm_ref_string_reset(NMRefString **ptr, NMRefString *str)
{
NMRefString *rstr;
nm_assert(ptr);
rstr = *ptr;
if (rstr == str)
return FALSE;
*ptr = nm_ref_string_ref(str);
nm_ref_string_unref(rstr);
return TRUE;
}
/*****************************************************************************/
static inline const char *