about summary refs log tree commit diff
path: root/src/libnm-glib-aux/nm-ref-string.h
diff options
context:
space:
mode:
authorMichael Biebl <biebl@debian.org>2023-02-10 11:51:50 +0100
committerMichael Biebl <biebl@debian.org>2023-02-10 11:51:50 +0100
commit58dddb802071d967ff5731f3333239ead78248e8 (patch)
treedef9e578e4786f8cbc56ce1b6cabf7670e00ae81 /src/libnm-glib-aux/nm-ref-string.h
parent2c1b7a7ea3c332b4d690c0595ef76c81de1f0cc8 (diff)
parent1372848511cb896b80b51ed1a3e9606bd9816631 (diff)
Update upstream source from tag 'upstream/1.42.0'
Update to upstream version '1.42.0'
with Debian dir 2b9fa2718b2bd34fa58008e335a0d81b87ad57cf
Diffstat (limited to 'src/libnm-glib-aux/nm-ref-string.h')
-rw-r--r--src/libnm-glib-aux/nm-ref-string.h19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/libnm-glib-aux/nm-ref-string.h b/src/libnm-glib-aux/nm-ref-string.h
index eb3c38de..1b0cabf2 100644
--- a/src/libnm-glib-aux/nm-ref-string.h
+++ b/src/libnm-glib-aux/nm-ref-string.h
@@ -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 *
@@ -139,7 +156,7 @@ nm_ref_string_equal_str(NMRefString *rstr, const char *str)
     /* We don't use streq() here, because an NMRefString might have embedded NUL characters
      * (as the length is tracked separately). The NUL terminated C string @str must not
      * compare equal to such a @rstr, thus we first explicitly check strlen(). */
-    return rstr->len == strlen(str) && (rstr->str == str || memcmp(rstr->str, str, rstr->len) == 0);
+    return rstr->str == str || (rstr->len == strlen(str) && memcmp(rstr->str, str, rstr->len) == 0);
 }
 
 static inline gboolean