From d550eef02d8ff9a94cb57ba90cd0edeebc6e3f1f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Fri, 24 Jul 2020 13:54:49 +0200 Subject: [PATCH] shared: add nm_strv_ptrarray_cmp() helper --- shared/nm-glib-aux/nm-shared-utils.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h index b4470fceb2..bff62b3226 100644 --- a/shared/nm-glib-aux/nm-shared-utils.h +++ b/shared/nm-glib-aux/nm-shared-utils.h @@ -1879,6 +1879,20 @@ nm_strv_ptrarray_contains (const GPtrArray *strv, return nm_strv_ptrarray_find_first (strv, str) >= 0; } +static inline int +nm_strv_ptrarray_cmp (const GPtrArray *a, + const GPtrArray *b) +{ + /* _nm_utils_strv_cmp_n() will treat NULL and empty arrays the same. + * That means, an empty strv array can both be represented by NULL + * and an array of length zero. + * If you need to distinguish between these case, do that yourself. */ + return _nm_utils_strv_cmp_n ((const char *const*) nm_g_ptr_array_pdata (a), + nm_g_ptr_array_len (a), + (const char *const*) nm_g_ptr_array_pdata (b), + nm_g_ptr_array_len (b)); +} + /*****************************************************************************/ int nm_utils_getpagesize (void);