From 190a8ed425c11ccb72d0fc90ab107a23b42fa8db Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 29 Jan 2020 17:46:22 +0100 Subject: [PATCH] shared: add nm_ref_string_equals_str() helper --- shared/nm-glib-aux/nm-ref-string.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/shared/nm-glib-aux/nm-ref-string.h b/shared/nm-glib-aux/nm-ref-string.h index c80b75eab9..a71d27db3f 100644 --- a/shared/nm-glib-aux/nm-ref-string.h +++ b/shared/nm-glib-aux/nm-ref-string.h @@ -49,6 +49,18 @@ nm_ref_string_get_len (NMRefString *rstr) return rstr ? rstr->len : 0u; } +static inline gboolean +nm_ref_string_equals_str (NMRefString *rstr, const char *s) +{ + /* Note that rstr->len might be greater than strlen(rstr->str). This function does + * not cover that and would ignore everything after the first NUL byte. If you need + * that distinction, this function is not for you. */ + + return rstr + ? nm_streq (rstr->str, s) + : (s == NULL); +} + static inline gboolean NM_IS_REF_STRING (const NMRefString *rstr) {