glib-aux/trival: add code comment to nm_ref_string_equal_str()

This commit is contained in:
Thomas Haller 2022-01-27 14:35:38 +01:00
parent b755539aa6
commit 6ae6edb6a8
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -136,6 +136,9 @@ nm_ref_string_equal_str(NMRefString *rstr, const char *str)
if (!rstr)
return FALSE;
/* 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);
}