shared: add nm_utils_g_slist_strlist_join() util

This commit is contained in:
Thomas Haller 2019-09-26 09:47:55 +02:00
parent ad3ef326aa
commit efa51ba9a2
2 changed files with 20 additions and 0 deletions

View file

@ -2871,6 +2871,24 @@ nm_utils_g_slist_strlist_cmp (const GSList *a, const GSList *b)
}
}
char *
nm_utils_g_slist_strlist_join (const GSList *a, const char *separator)
{
GString *str = NULL;
if (!a)
return NULL;
for (; a; a = a->next) {
if (!str)
str = g_string_new (NULL);
else
g_string_append (str, separator);
g_string_append (str, a->data);
}
return g_string_free (str, FALSE);
}
/*****************************************************************************/
gpointer

View file

@ -993,6 +993,8 @@ GSList *nm_utils_g_slist_find_str (const GSList *list,
int nm_utils_g_slist_strlist_cmp (const GSList *a, const GSList *b);
char *nm_utils_g_slist_strlist_join (const GSList *a, const char *separator);
/*****************************************************************************/
gssize nm_utils_ptrarray_find_binary_search (gconstpointer *list,