mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 04:08:01 +02:00
glib-aux: add nm_ref_string_{equal,cmp}() helpers
This commit is contained in:
parent
8f5684543f
commit
043cdda00b
1 changed files with 20 additions and 0 deletions
|
|
@ -94,6 +94,26 @@ nm_ref_string_get_len(NMRefString *rstr)
|
|||
return rstr ? rstr->len : 0u;
|
||||
}
|
||||
|
||||
static inline gboolean
|
||||
nm_ref_string_equal(NMRefString *a, NMRefString *b)
|
||||
{
|
||||
return a == b;
|
||||
}
|
||||
|
||||
static inline int
|
||||
nm_ref_string_cmp(NMRefString *a, NMRefString *b)
|
||||
{
|
||||
NM_CMP_SELF(a, b);
|
||||
|
||||
/* It would be cheaper to first compare by length. But this
|
||||
* way we get a nicer, ASCIIbethical sort order. */
|
||||
NM_CMP_DIRECT_MEMCMP(a->str, b->str, NM_MIN(a->len, b->len));
|
||||
NM_CMP_DIRECT(a->len, b->len);
|
||||
return nm_assert_unreachable_val(0);
|
||||
}
|
||||
|
||||
#define NM_CMP_DIRECT_REF_STRING(a, b) NM_CMP_RETURN_DIRECT(nm_ref_string_cmp((a), (b)))
|
||||
|
||||
static inline gboolean
|
||||
nm_ref_string_equals_str(NMRefString *rstr, const char *str)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue