diff options
author | Beniamino Galvani <bgalvani@redhat.com> | 2015-07-16 10:36:19 +0200 |
---|---|---|
committer | Beniamino Galvani <bgalvani@redhat.com> | 2015-08-04 08:46:11 +0200 |
commit | d49fcd07d137bd8df89486d01e61c490558c2a1f (patch) | |
tree | a3ffcc5153bb184a3acb8b58583a53178b73ce92 | |
parent | 4fb0d62802ac10c4138f1a6f5a82b47f0c6d75e8 (diff) | |
download | NetworkManager-d49fcd07d137bd8df89486d01e61c490558c2a1f.tar.gz |
libnm-core: add _nm_utils_strv_equal()
-rw-r--r-- | libnm-core/nm-core-internal.h | 1 | ||||
-rw-r--r-- | libnm-core/nm-utils.c | 24 |
2 files changed, 25 insertions, 0 deletions
diff --git a/libnm-core/nm-core-internal.h b/libnm-core/nm-core-internal.h index ea095a6510..4081a32990 100644 --- a/libnm-core/nm-core-internal.h +++ b/libnm-core/nm-core-internal.h @@ -135,6 +135,7 @@ char ** _nm_utils_slist_to_strv (GSList *slist, gboolean deep_copy); GPtrArray * _nm_utils_strv_to_ptrarray (char **strv); char ** _nm_utils_ptrarray_to_strv (GPtrArray *ptrarray); +gboolean _nm_utils_strv_equal (char **strv1, char **strv2); gboolean _nm_utils_check_file (const char *filename, gint64 check_owner, diff --git a/libnm-core/nm-utils.c b/libnm-core/nm-utils.c index 89fa812d73..0ed4814619 100644 --- a/libnm-core/nm-utils.c +++ b/libnm-core/nm-utils.c @@ -846,6 +846,30 @@ _nm_utils_ptrarray_to_strv (GPtrArray *ptrarray) } /** + * _nm_utils_strv_equal: + * @strv1: a string array + * @strv2: a string array + * + * Compare NULL-terminated string arrays for equality. + * + * Returns: %TRUE if the arrays are equal, %FALSE otherwise. + **/ +gboolean +_nm_utils_strv_equal (char **strv1, char **strv2) +{ + if (strv1 == strv2) + return TRUE; + + if (!strv1 || !strv2) + return FALSE; + + for ( ; *strv1 && *strv2 && !strcmp (*strv1, *strv2); strv1++, strv2++) + ; + + return !*strv1 && !*strv2; +} + +/** * _nm_utils_strsplit_set: * @str: string to split * @delimiters: string of delimiter characters |