mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-11 09:18:38 +02:00
Add nm_utils_g_ptr_array_add_string_item convenience function
This commit is contained in:
parent
acbd5781e7
commit
0b04d9ad83
2 changed files with 22 additions and 0 deletions
|
|
@ -4161,6 +4161,26 @@ nm_utils_g_value_set_strv(GValue *value, GPtrArray *strings)
|
|||
g_value_take_boxed(value, strv);
|
||||
}
|
||||
|
||||
void
|
||||
nm_utils_g_ptr_array_add_string_item(GPtrArray *array, const char *str, gboolean dup)
|
||||
{
|
||||
int i;
|
||||
|
||||
g_return_if_fail(array != NULL);
|
||||
g_return_if_fail(str != NULL);
|
||||
|
||||
/* Check for dupes before adding */
|
||||
for (i = 0; i < array->len; i++) {
|
||||
const char *candidate = g_ptr_array_index(array, i);
|
||||
|
||||
if (candidate && nm_streq(candidate, str))
|
||||
return;
|
||||
}
|
||||
|
||||
/* No dupes, add the new item */
|
||||
g_ptr_array_add(array, dup ? g_strdup(str) : (gpointer) str);
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *
|
||||
|
|
|
|||
|
|
@ -423,6 +423,8 @@ void _nm_utils_set_testing(NMUtilsTestFlags flags);
|
|||
|
||||
void nm_utils_g_value_set_strv(GValue *value, GPtrArray *strings);
|
||||
|
||||
void nm_utils_g_ptr_array_add_string_item(GPtrArray *array, const char *str, gboolean dup);
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
const char *nm_utils_dnsmasq_status_to_string(int status, char *dest, gsize size);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue